Class: Money::Bank::Cryptocompare
- Inherits:
-
VariableExchange
- Object
- VariableExchange
- Money::Bank::Cryptocompare
- Defined in:
- lib/money/bank/cryptocompare.rb
Instance Method Summary collapse
- #get_rate(from, to, opts = {}) ⇒ Object
-
#initialize(rates_store: nil, options: {}, &block) ⇒ Cryptocompare
constructor
A new instance of Cryptocompare.
Constructor Details
#initialize(rates_store: nil, options: {}, &block) ⇒ Cryptocompare
Returns a new instance of Cryptocompare.
7 8 9 10 11 12 |
# File 'lib/money/bank/cryptocompare.rb', line 7 def initialize(rates_store: nil, options: {}, &block) @cyptocompare_options = rates_store ||= Money::RatesStore::Memory.new super(rates_store, &block) end |
Instance Method Details
#get_rate(from, to, opts = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/money/bank/cryptocompare.rb', line 14 def get_rate(from, to, opts = {}) rate = super if rate rate else # Fetch exchange rate info = ::Cryptocompare::Price.find(from, to, @cyptocompare_options) if info["Response"] == "Error" return nil end add_rate(from, to, info[from.to_s][to.to_s]) end end |