Sha256: 47387b41f89b7a80a89cfd722972fd950371a1f9616617732945e71457582f2b

Contents?: true

Size: 742 Bytes

Versions: 7

Compression:

Stored size: 742 Bytes

Contents

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

      # 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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
money-6.13.2 lib/money/currency/loader.rb
money-6.13.1 lib/money/currency/loader.rb
money-6.13.0 lib/money/currency/loader.rb
money-6.12.0 lib/money/currency/loader.rb
money-6.11.3 lib/money/currency/loader.rb
money-6.11.2 lib/money/currency/loader.rb
money-6.11.1 lib/money/currency/loader.rb