Class: CbrCurrency::Currency
- Inherits:
-
Object
- Object
- CbrCurrency::Currency
- Defined in:
- lib/cbr_currency/currency.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#date ⇒ Object
Returns the value of attribute date.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(code:, cost:, title:, amount: 1, date:) ⇒ Currency
constructor
A new instance of Currency.
Constructor Details
#initialize(code:, cost:, title:, amount: 1, date:) ⇒ Currency
Returns a new instance of Currency.
5 6 7 8 9 10 11 12 |
# File 'lib/cbr_currency/currency.rb', line 5 def initialize(code:, cost:, title:, amount: 1, date:) raise ArgumentError.new("some of params (code, cost, title, amount) is nil") unless code && cost && title && date @code = code.downcase.to_sym @rate = normalize_rate cost, amount @title = title @date = Date.parse(date) end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/cbr_currency/currency.rb', line 3 def code @code end |
#date ⇒ Object
Returns the value of attribute date.
3 4 5 |
# File 'lib/cbr_currency/currency.rb', line 3 def date @date end |
#rate ⇒ Object
Returns the value of attribute rate.
3 4 5 |
# File 'lib/cbr_currency/currency.rb', line 3 def rate @rate end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/cbr_currency/currency.rb', line 3 def title @title end |