Class: NbpExchange::Rate

Inherits:
Object
  • Object
show all
Defined in:
lib/nbp_exchange/rate.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(currency, date, aer) ⇒ Rate

Returns a new instance of Rate.



7
8
9
10
11
# File 'lib/nbp_exchange/rate.rb', line 7

def initialize(currency, date, aer)
  @date = date
  @currency = currency
  @average_exchange_rate = aer
end

Instance Attribute Details

#average_exchange_rateObject (readonly)

Returns the value of attribute average_exchange_rate.



5
6
7
# File 'lib/nbp_exchange/rate.rb', line 5

def average_exchange_rate
  @average_exchange_rate
end

#currencyObject (readonly)

Returns the value of attribute currency.



3
4
5
# File 'lib/nbp_exchange/rate.rb', line 3

def currency
  @currency
end

#dateObject (readonly)

Returns the value of attribute date.



4
5
6
# File 'lib/nbp_exchange/rate.rb', line 4

def date
  @date
end

Class Method Details

.parse(currency, date, raw) ⇒ Object



13
14
15
16
17
# File 'lib/nbp_exchange/rate.rb', line 13

def self.parse(currency, date, raw)
  aer = raw.xpath("kurs_sredni").text
  aer = aer.gsub(',','.').to_f
  Rate.new(currency, date, aer)
end