Class: Plurimath::NumberFormatter
- Inherits:
-
Object
- Object
- Plurimath::NumberFormatter
- Defined in:
- lib/plurimath/number_formatter.rb
Instance Attribute Summary collapse
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#localize_number ⇒ Object
Returns the value of attribute localize_number.
-
#localizer_symbols ⇒ Object
Returns the value of attribute localizer_symbols.
Instance Method Summary collapse
-
#initialize(locale = "en", localize_number: nil, localizer_symbols: {}) ⇒ NumberFormatter
constructor
A new instance of NumberFormatter.
- #localized_number(number_string, locale: @locale, precision: nil, format: {}) ⇒ Object
- #twitter_cldr_reader(locale: @locale) ⇒ Object
Constructor Details
#initialize(locale = "en", localize_number: nil, localizer_symbols: {}) ⇒ NumberFormatter
Returns a new instance of NumberFormatter.
7 8 9 10 11 |
# File 'lib/plurimath/number_formatter.rb', line 7 def initialize(locale = "en", localize_number: nil, localizer_symbols: {}) @locale = supported_locale(locale) @localize_number = localize_number @localizer_symbols = localizer_symbols end |
Instance Attribute Details
#locale ⇒ Object
Returns the value of attribute locale.
5 6 7 |
# File 'lib/plurimath/number_formatter.rb', line 5 def locale @locale end |
#localize_number ⇒ Object
Returns the value of attribute localize_number.
5 6 7 |
# File 'lib/plurimath/number_formatter.rb', line 5 def localize_number @localize_number end |
#localizer_symbols ⇒ Object
Returns the value of attribute localizer_symbols.
5 6 7 |
# File 'lib/plurimath/number_formatter.rb', line 5 def localizer_symbols @localizer_symbols end |
Instance Method Details
#localized_number(number_string, locale: @locale, precision: nil, format: {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/plurimath/number_formatter.rb', line 13 def localized_number(number_string, locale: @locale, precision: nil, format: {}) Formatter::NumericFormatter.new( supported_locale(locale), localize_number: localize_number, localizer_symbols: localizer_symbols, ).localized_number( number_string, locale: supported_locale(locale), precision: precision, format: format, ) end |
#twitter_cldr_reader(locale: @locale) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/plurimath/number_formatter.rb', line 26 def twitter_cldr_reader(locale: @locale) Formatter::NumericFormatter.new( supported_locale(locale), localize_number: localize_number, localizer_symbols: localizer_symbols, ).twitter_cldr_reader end |