Converted to a gem and made stylistic changes to closer conform to the Github Ruby styleguide at https://github.com/styleguide/ruby.