Code adapted for Ruby.
Merge pull request #3 from PaulMarclay/master

Code adapted for Ruby. Thanks @PaulMarclay