Converting a Python Script to Ruby

Can anyone assist me with converting this python script to ruby?

I’m having difficulty reading python even though it is similar to Ruby.

Thank you in advance for any help.