module TwitterCldr::Shared::Currencies

Public Class Methods

currency_codes(locale = :en) click to toggle source
# File lib/twitter_cldr/shared/currencies.rb, line 10
def currency_codes(locale = :en)
  resource(locale).keys.map { |c| c.to_s }
end
for_code(currency_code, locale = :en) click to toggle source
# File lib/twitter_cldr/shared/currencies.rb, line 14
def for_code(currency_code, locale = :en)
  currency_code = currency_code.to_sym
  data = resource(locale)[currency_code]
  symbol_data = iso_currency_symbols[currency_code]

  if data
    result = {
      currency:    currency_code,
      name:        data[:one],
      cldr_symbol: data[:symbol] || currency_code.to_s,
      symbol:      data[:symbol] || currency_code.to_s,
      code_points: (data[:symbol] || currency_code.to_s).unpack("U*")
    }

    result.merge!(symbol_data) if symbol_data
  end

  result
end

Private Class Methods

iso_currency_symbols() click to toggle source

ISO 4217 to be precise

# File lib/twitter_cldr/shared/currencies.rb, line 37
def iso_currency_symbols
  @iso_currency_symbols ||= TwitterCldr.get_resource(:shared, :iso_currency_symbols)
end
resource(locale) click to toggle source
# File lib/twitter_cldr/shared/currencies.rb, line 41
def resource(locale)
  locale = locale.to_sym
  @resource ||= {}
  @resource[locale] ||= TwitterCldr.get_resource(:locales, locale, :currencies)[locale][:currencies]
end