module CurrencyData

Constants

CURRENCIES
VERSION

Public Instance Methods

find(iso_code) click to toggle source
# File lib/currency_data.rb, line 10
def find iso_code
  data = table[iso_code.to_s.downcase.to_sym]
  data && OpenStruct.new(data).freeze
end
table() click to toggle source
# File lib/currency_data.rb, line 15
def table
  @table ||= begin
    json = File.read(CURRENCIES)
    hash = JSON.parse(json, symbolize_names: true)

    hash.each do |code, attributes|
      attributes[:prefered_symbol] ||= attributes[:symbol]
      attributes[:decimal_places] ||= 2
    end

    hash.freeze
  end
end