Module: TwitterCldr::Shared::Currencies

Defined in:
lib/twitter_cldr/shared/currencies.rb

Constant Summary collapse

@@resource =
TwitterCldr.get_resource(:shared, :currencies)[:shared][:currencies]

Class Method Summary collapse

Class Method Details

.countriesObject


14
15
16
# File 'lib/twitter_cldr/shared/currencies.rb', line 14

def countries
  @@resource.map { |country_name, data| country_name.to_s }
end

.currency_codesObject


18
19
20
# File 'lib/twitter_cldr/shared/currencies.rb', line 18

def currency_codes
  @@resource.map { |country_name, data| data[:code] }
end

.for_code(currency_code) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/twitter_cldr/shared/currencies.rb', line 26

def for_code(currency_code)
  final = nil
  @@resource.each_pair do |country_name, data|
    if data[:code] == currency_code
      final = data.merge({ :country => country_name.to_s })
      final.delete(:code)
      break
    end
  end
  final
end

.for_country(country_name) ⇒ Object


22
23
24
# File 'lib/twitter_cldr/shared/currencies.rb', line 22

def for_country(country_name)
  @@resource[country_name.to_sym]
end