ruby implementation of crop