Porting command line application from PHP to Ruby