Class: Danconia::Exchange

Inherits:
Object
  • Object
show all
Defined in:
lib/danconia/exchange.rb

Instance Method Summary collapse

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.

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/danconia/exchange.rb', line 15

def rates **_opts
  raise NotImplementedError
end