class Bnb::Rates
Public Class Methods
new()
click to toggle source
# File lib/bnb/rates.rb, line 9 def initialize @rates = {} end
Public Instance Methods
[](key)
click to toggle source
# File lib/bnb/rates.rb, line 25 def [] key @rates[key] end
fetch()
click to toggle source
# File lib/bnb/rates.rb, line 13 def fetch response = HTTParty.get('http://www.bnb.bg/Statistics/StExternalSector/StExchangeRates/StERForeignCurrencies/index.htm?download=xml&search=&lang=BG') rows = response.parsed_response['ROWSET']['ROW'] rows.each do |item| rate = Bnb::Rate.new.from_bnb(item) @rates[rate.code] = rate end self end