Sha256: 0b66361f0ab5d39515cc95709fccea9516cb107e278f9e8330b97259d3fc3dd2

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

require 'json'
require 'open-uri'
require 'money/distributed/fetcher/base'

class Money
  module Distributed
    module Fetcher
      # Fetcher that loads rates from a file
      class File
        include Base

        def initialize(file_path, bank = nil)
          super(bank)
          @file_path = file_path
        end

        private

        def exchange_rates
          open(@file_path).read.split("\n").each_with_object({}) do |line, h|
            code_rate = line.split(' ')
            h[code_rate[0]] = BigDecimal.new(code_rate[1])
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
money-distributed-0.0.2.2 lib/money/distributed/fetcher/file.rb