Class: SpellNumber::Speller
- Inherits:
-
Object
- Object
- SpellNumber::Speller
- Defined in:
- lib/spell_number/speller.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Speller
constructor
A new instance of Speller.
- #number_to_words(number) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Speller
Returns a new instance of Speller.
5 6 7 |
# File 'lib/spell_number/speller.rb', line 5 def initialize( = {}) @options = end |
Instance Method Details
#number_to_words(number) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spell_number/speller.rb', line 9 def number_to_words(number) return number_with_thousands(number) if(number < 1000000) rest = number % 1000000 singular = ((number / 1000000) == 1) millions = number_with_thousands(number / 1000000) rest_in_words = number_with_thousands(rest) words = 'not_found' words = I18n.t("spell_number.formats.millions_singular.#{format_subtype(rest)}", :locale => @options[:locale], :million_count => millions, :rest => rest_in_words, :default => 'not_found') if(singular) words = I18n.t("spell_number.formats.millions.#{format_subtype(rest)}", :locale => @options[:locale], :million_count => millions, :rest => rest_in_words) if(words == 'not_found') words end |