Hi all, Is there a way to convert number to words in Ruby?? eg., if the number is 35764, then the word should be Thirty Five Thousand Seven Hundred and Sixty Four if it is 345 then Three Hundred and forty five. Can any one please tell me the way to do?? Like any plugin or gems or any method available in ROR?? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Naga harish Kanegolla wrote:> Is there a way to convert number to words in Ruby?? > eg., if the number is 35764, then the word should be > Thirty Five Thousand Seven Hundred and Sixty Four > if it is 345 then Three Hundred and forty five. > Can any one please tell me the way to do?? > Like any plugin or gems or any method available in ROR??If I remember correctly there was a Ruby Quiz that did just this. You should be able to find it in the Ruby-talk archives or perhaps the Pragmatic Programmer''s Best of Ruby Quiz book. -- Roderick van Domburg http://www.nedforce.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Roderick van Domburg wrote:> Naga harish Kanegolla wrote: >> Is there a way to convert number to words in Ruby?? >> eg., if the number is 35764, then the word should be >> Thirty Five Thousand Seven Hundred and Sixty Four >> if it is 345 then Three Hundred and forty five. >> Can any one please tell me the way to do?? >> Like any plugin or gems or any method available in ROR?? > > If I remember correctly there was a Ruby Quiz that did just this. You > should be able to find it in the Ruby-talk archives or perhaps the > Pragmatic Programmer''s Best of Ruby Quiz book. > > -- > Roderick van Domburg > http://www.nedforce.comHi, This is an example used in Chris Pine''s learn to program http://pine.fm/LearnToProgram/?Chapter=08 (scroll down) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Roderick van Domburg wrote:> If I remember correctly there was a Ruby Quiz that did just this. You > should be able to find it in the Ruby-talk archives or perhaps the > Pragmatic Programmer''s Best of Ruby Quiz book. > > -- > Roderick van Domburg > http://www.nedforce.comYeah, RubyQuiz used the same thing again a couple of weeks ago. Equally, there''s a gem called "Linguistics" which happens to do this require ''Linguistics'' Linguistics.use(:en) 453.to_s.en.numwords => "four hundred and fifty-three" -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 21, 2007, at 3:49 PM, Matthew Rudy wrote:> Roderick van Domburg wrote: > >> If I remember correctly there was a Ruby Quiz that did just this. You >> should be able to find it in the Ruby-talk archives or perhaps the >> Pragmatic Programmer''s Best of Ruby Quiz book. >> >> -- >> Roderick van Domburg >> http://www.nedforce.com > > Yeah, > RubyQuiz used the same thing again a couple of weeks ago. > Equally, there''s a gem called "Linguistics" which happens to do this > > require ''Linguistics'' > Linguistics.use(:en) > > 453.to_s.en.numwords => "four hundred and fifty-three"Except that it should be written: "four hundred fifty-three" (i.e., without the "and") -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
Naga, How about something like here http://codersifu.blogspot.com/2007/08/mymoney-convert-money-to-word.html I did it to convert money to word. On Sep 22, 4:57 am, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On Sep 21, 2007, at 3:49 PM, Matthew Rudy wrote: > > > > > Roderick van Domburg wrote: > > >> If I remember correctly there was a Ruby Quiz that did just this. You > >> should be able to find it in the Ruby-talk archives or perhaps the > >> Pragmatic Programmer''s Best of Ruby Quiz book. > > >> -- > >> Roderick van Domburg > >>http://www.nedforce.com > > > Yeah, > > RubyQuiz used the same thing again a couple of weeks ago. > > Equally, there''s a gem called "Linguistics" which happens to do this > > > require ''Linguistics'' > > Linguistics.use(:en) > > > 453.to_s.en.numwords => "four hundred and fifty-three" > > Except that it should be written: > "four hundred fifty-three" > > (i.e., without the "and") > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org > > smime.p7s > 3KDownload--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Rudy wrote:> Roderick van Domburg wrote: > >> If I remember correctly there was a Ruby Quiz that did just this. You >> should be able to find it in the Ruby-talk archives or perhaps the >> Pragmatic Programmer''s Best of Ruby Quiz book. >> >> -- >> Roderick van Domburg >> http://www.nedforce.com > > Yeah, > RubyQuiz used the same thing again a couple of weeks ago. > Equally, there''s a gem called "Linguistics" which happens to do this > > require ''Linguistics'' > Linguistics.use(:en) > > 453.to_s.en.numwords => "four hundred and fifty-three"Thanks a lot for all the good responses. I tried using the Linguistics gem. But I have a small doubt. Actually I am using this to convert the rupee number to word format. So usually I used to print Rs 13,435.50 But this linguistic gem converted into "thirteen thousand, four hundred and thirty-five point five". It looks annoying if its point five. Is there a option to exclude that point five and insert "fifty paise" ?? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 9/22/07, Naga harish Kanegolla <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > 453.to_s.en.numwords => "four hundred and fifty-three" > > Thanks a lot for all the good responses. I tried using the Linguistics > gem. But I have a small doubt. > > Actually I am using this to convert the rupee number to word format. So > usually I used to print Rs 13,435.50 But this linguistic gem converted > into "thirteen thousand, four hundred and thirty-five point five". It > looks annoying if its point five. Is there a option to exclude that > point five and insert "fifty paise" ?? >you could try something like def currency_to_word(amount) currency = amount.to_s.split(/./) currency[0].en.numwords + " rupee and " + currency[1].en.numwords + " paise" end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Try num2en plugin, svn export http://svn.creopolis.com/num_to_english/trunk made by Elad, (http://pandejo.blogspot.com/) if you want it multilanguaged you''ll need to work some.. :) http://www.yulia-site.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---