convert python script to ruby