Changed code to use more idiomatic Ruby. Added regex to determine Python version