Module: Money::Distributed::Fetcher::Base

Included in:
File
Defined in:
lib/money/distributed/fetcher/base.rb

Overview

Base class for reates fetchers

Instance Method Summary collapse

Instance Method Details

#fetchObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/money/distributed/fetcher/base.rb', line 12

def fetch
  rates = exchange_rates
  currencies = rates.keys

  currencies.each { |cur| add_rate(cur, cur, 1) }

  currencies.combination(2).each do |curr1, curr2|
    rate = rates[curr2] / rates[curr1]
    add_rate(curr1, curr2, rate)
  end
end

#initialize(bank = nil) ⇒ Object



8
9
10
# File 'lib/money/distributed/fetcher/base.rb', line 8

def initialize(bank = nil)
  @bank = bank || Money.default_bank
end