Displaying 2 results from an estimated 2 matches for "commify".
Did you mean:
codify
2006 Jan 24
7
formatting numbers with commas
I needed to format numbers with commas to make it more human
readable. Here''s how I did it.
def commify(number)
c = { :value => "", :length => 0 }
r = number.to_s.reverse.split("").inject(c) do |t, e|
iv, il = t[:value], t[:length]
iv += '','' if il % 3 == 0 && il != 0
{ :value => iv + e, :length => il + 1 }
e...
2006 Apr 30
8
format numbers as words
Does anyone know if there is a function available which can format any
entered number as words?
eg: ''1234'' would be ''One Thousand Two Hundred and Thirty Four''
In the past, I would have said this is a tall order, but from what I''ve
seen with playing with rails for a short time, I don''t know what to
expect. :)
Thanks for any help,
Damien