Class: CentralBankOfRussia

Inherits:
Money::Bank::VariableExchange
  • Object
show all
Defined in:
lib/central_bank_of_russia.rb

Constant Summary collapse

CBR_RATES_URL =
'http://www.cbr.ru/scripts/XML_daily.asp'

Instance Method Summary collapse

Instance Method Details

#update_rates(date = Date.today) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/central_bank_of_russia.rb', line 9

def update_rates(date=Date.today)
  rates = parse_rates(open(CBR_RATES_URL + '?date_req=' + date.strftime('%d/%m/%Y')))
  rates.each do |currency, rate|
    begin
      add_rate currency, 'RUB', rate
      add_rate 'RUB', currency, 1/rate
    rescue Money::Currency::UnknownCurrency
      # skip
    end
  end
  self
end