Sha256: 2a56e697997c95690ab9b3c6ccc28f3e96546beb6c8e24f895eb042511133c23

Contents?: true

Size: 927 Bytes

Versions: 8

Compression:

Stored size: 927 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Shared
    module Currencies

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

      class << self

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

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

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

        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

      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
twitter_cldr-1.6.2 lib/twitter_cldr/shared/currencies.rb
twitter_cldr-1.6.1 lib/twitter_cldr/shared/currencies.rb
twitter_cldr-1.6.0 lib/twitter_cldr/shared/currencies.rb
twitter_cldr-1.5.0 lib/twitter_cldr/shared/currencies.rb
twitter_cldr-1.4.1 lib/twitter_cldr/shared/currencies.rb
twitter_cldr-1.4.0 lib/twitter_cldr/shared/currencies.rb
twitter_cldr-1.3.6 lib/twitter_cldr/shared/currencies.rb
twitter_cldr-1.3.0 lib/twitter_cldr/shared/currencies.rb