finish ruby implementation