Class: Danconia::Exchange
- Inherits:
-
Object
- Object
- Danconia::Exchange
- Defined in:
- lib/danconia/exchange.rb
Direct Known Subclasses
Danconia::Exchanges::BNA, Danconia::Exchanges::CurrencyLayer, Danconia::Exchanges::FixedRates
Instance Method Summary collapse
- #rate(from, to, **opts) ⇒ Object
-
#rates(**_opts) ⇒ Object
Override this method in subclasses.
Instance Method Details
#rate(from, to, **opts) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/danconia/exchange.rb', line 5 def rate from, to, **opts return 1.0 if from == to pair = Pair.new(from, to) rates = direct_and_inverted_rates(opts) rates[pair] or indirect_rate(pair, rates) or raise Errors::ExchangeRateNotFound.new(from, to) end |
#rates(**_opts) ⇒ Object
Override this method in subclasses. Should return a map of pairs to rates. See `FixedRates` for an example implementation.
15 16 17 |
# File 'lib/danconia/exchange.rb', line 15 def rates **_opts raise NotImplementedError end |