Class: Money::Bank::RussianCentralBank
- Inherits:
-
VariableExchange
- Object
- VariableExchange
- Money::Bank::RussianCentralBank
- Defined in:
- lib/money/bank/russian_central_bank.rb
Instance Attribute Summary collapse
-
#rates_expired_at ⇒ Object
readonly
Returns the value of attribute rates_expired_at.
-
#rates_updated_at ⇒ Object
readonly
Returns the value of attribute rates_updated_at.
-
#rates_updated_on ⇒ Object
readonly
Returns the value of attribute rates_updated_on.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
Instance Method Summary collapse
- #add_rate(from, to, rate) ⇒ Object
- #flush_rates ⇒ Object
- #get_rate(from, to) ⇒ Object
- #rates_expired? ⇒ Boolean
- #update_rates(date = Date.today) ⇒ Object
Instance Attribute Details
#rates_expired_at ⇒ Object (readonly)
Returns the value of attribute rates_expired_at.
6 7 8 |
# File 'lib/money/bank/russian_central_bank.rb', line 6 def rates_expired_at @rates_expired_at end |
#rates_updated_at ⇒ Object (readonly)
Returns the value of attribute rates_updated_at.
6 7 8 |
# File 'lib/money/bank/russian_central_bank.rb', line 6 def rates_updated_at @rates_updated_at end |
#rates_updated_on ⇒ Object (readonly)
Returns the value of attribute rates_updated_on.
6 7 8 |
# File 'lib/money/bank/russian_central_bank.rb', line 6 def rates_updated_on @rates_updated_on end |
#ttl ⇒ Object
Returns the value of attribute ttl.
6 7 8 |
# File 'lib/money/bank/russian_central_bank.rb', line 6 def ttl @ttl end |
Instance Method Details
#add_rate(from, to, rate) ⇒ Object
22 23 24 25 |
# File 'lib/money/bank/russian_central_bank.rb', line 22 def add_rate(from, to, rate) super(from, to, rate) super(to, from, 1.0 / rate) end |
#flush_rates ⇒ Object
8 9 10 |
# File 'lib/money/bank/russian_central_bank.rb', line 8 def flush_rates @store = Money::RatesStore::Memory.new end |
#get_rate(from, to) ⇒ Object
27 28 29 30 |
# File 'lib/money/bank/russian_central_bank.rb', line 27 def get_rate(from, to) update_rates if rates_expired? super || indirect_rate(from, to) end |
#rates_expired? ⇒ Boolean
38 39 40 |
# File 'lib/money/bank/russian_central_bank.rb', line 38 def rates_expired? rates_expired_at && rates_expired_at <= Time.now end |
#update_rates(date = Date.today) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/money/bank/russian_central_bank.rb', line 12 def update_rates(date = Date.today) store.transaction do update_parsed_rates(exchange_rates(date)) @rates_updated_at = Time.now @rates_updated_on = date update_expired_at store.send(:rates) end end |