Sha256: a11d6153564826884035d9a2435a0061c91531b7c5237caea6b0e324cbeb1266

Contents?: true

Size: 800 Bytes

Versions: 12

Compression:

Stored size: 800 Bytes

Contents

class Money
  class Currency
    module Loader
      DATA_PATH = File.expand_path("../../../../config", __FILE__)

      class << self
        # Loads and returns the currencies stored in JSON files in the config directory.
        #
        # @return [Hash]
        def load_currencies
          currencies = parse_currency_file("currency_iso.json")
          currencies.merge! parse_currency_file("currency_non_iso.json")
          currencies.merge! parse_currency_file("currency_backwards_compatible.json")
        end

        private

        def parse_currency_file(filename)
          json = File.read("#{DATA_PATH}/#{filename}")
          json.force_encoding(::Encoding::UTF_8) if defined?(::Encoding)
          JSON.parse(json, symbolize_names: true)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
money-6.19.0 lib/money/currency/loader.rb
money-6.18.0 lib/money/currency/loader.rb
money-6.17.0 lib/money/currency/loader.rb
money-6.16.0 lib/money/currency/loader.rb
money-6.14.1 lib/money/currency/loader.rb
money-6.14.0 lib/money/currency/loader.rb
money-6.13.8 lib/money/currency/loader.rb
money-6.13.7 lib/money/currency/loader.rb
money-6.13.6 lib/money/currency/loader.rb
money-6.13.5 lib/money/currency/loader.rb
money-6.13.4 lib/money/currency/loader.rb
money-6.13.3 lib/money/currency/loader.rb