Sunday, March 8, 2009

scottbarr-number_to_text RubyGem

I was playing around with a bit of Ruby to convert numbers to text a few weeks ago but never finished it and forgot all about it. Today Guest11057 (thats an extremely boring nick!) on the #rubyonrails IRC channel asked if something like this existed, and apparently it doesn't. That reminded me about the mothballed code, and motivated me to finish it off and package it up as a RubyGem. To convert a number to text:
n = Number.new(119)
puts n.to_text # => "one-hundred-and-nineteen"
I'm not happy with how the implementation came, but it does the job. I'll clean it up to work a bit nicer sometime :) If you need to convert numbers to text in Ruby, take a look at http://github.com/scottbarr/number_to_text/tree/master

No comments: