Class: NbpExchange::Rate
- Inherits:
-
Object
- Object
- NbpExchange::Rate
- Defined in:
- lib/nbp_exchange/rate.rb
Instance Attribute Summary collapse
-
#average_exchange_rate ⇒ Object
readonly
Returns the value of attribute average_exchange_rate.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(currency, date, aer) ⇒ Rate
constructor
A new instance of Rate.
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_rate ⇒ Object (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 |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
3 4 5 |
# File 'lib/nbp_exchange/rate.rb', line 3 def currency @currency end |
#date ⇒ Object (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 |