Refactoring of the code to match a more ruby style.

I used rubocop as configured in the .rubocop.yml for most of it.
Merge pull request #1 from netikular/master

Refactoring of the code to match a more ruby style.