Class: TwitterCldr::Formatters::CurrencyFormatter
- Inherits:
-
NumberFormatter
- Object
- Formatter
- NumberFormatter
- TwitterCldr::Formatters::CurrencyFormatter
- Defined in:
- lib/twitter_cldr/formatters/numbers/currency_formatter.rb
Instance Attribute Summary
Attributes inherited from NumberFormatter
Attributes inherited from Formatter
Instance Method Summary collapse
Methods inherited from NumberFormatter
Methods inherited from Formatter
Constructor Details
This class inherits a constructor from TwitterCldr::Formatters::NumberFormatter
Instance Method Details
#format(tokens, number, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/twitter_cldr/formatters/numbers/currency_formatter.rb', line 10 def format(tokens, number, = {}) [:currency] ||= "USD" [:locale] ||= :en currency = TwitterCldr::Shared::Currencies.for_code([:currency], [:locale]) currency ||= { currency: [:currency], symbol: [:currency], cldr_symbol: [:currency] } # overwrite with explicit symbol if given currency[:symbol] = [:symbol] if [:symbol] digits_and_rounding = resource([:currency]) [:precision] ||= digits_and_rounding[:digits] [:rounding] ||= digits_and_rounding[:rounding] symbol = [:use_cldr_symbol] ? currency[:cldr_symbol] : currency[:symbol] symbol ||= currency[:currency].to_s super.gsub('ยค', symbol) end |