Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number to English Word Conversion Rails

Anybody knows the method to convert the numericals to english number words in rails?

I found some Ruby scripts to convert numbericals to english words for corresponding words.

Instead of writing a script in ruby, i feel that direct function is available.

Eg. 1 -> One, 2 -> Two.

like image 244
Palani Kannan Avatar asked Oct 19 '10 07:10

Palani Kannan


2 Answers

Use the numbers_and_words gem, https://github.com/kslazarev/numbers_and_words

like image 162
dB. Avatar answered Sep 22 '22 23:09

dB.


The humanize gem that does exactly what you want:

require 'humanize' 23.humanize # => "twenty three" 0.42.humanize(decimals_as: :digits) # => "zero point four two" 
like image 43
Geoffroy Avatar answered Sep 21 '22 23:09

Geoffroy