Class: VlatkoDawanda::Bank

Inherits:
Object
  • Object
show all
Defined in:
lib/vlatko_dawanda/bank.rb

Instance Method Summary collapse

Instance Method Details

#conversion_rates(base_currency, currencies) ⇒ Object



4
5
6
# File 'lib/vlatko_dawanda/bank.rb', line 4

def conversion_rates(base_currency, currencies)
  @currencies = parse_currencies(base_currency, currencies)
end

#currenciesObject



8
9
10
# File 'lib/vlatko_dawanda/bank.rb', line 8

def currencies
  @currencies ||= {}
end

#find_currency(search) ⇒ Object

Raises:



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vlatko_dawanda/bank.rb', line 12

def find_currency(search)
  currency = case search
  when ::String, ::Symbol
    currencies[currency_id(search)]
  when Currency
    found = currencies[currency_id(search.iso_code)]
    raise UnknownCurrency.new('currency not matching the rate') unless found == search
    found
  end

  raise UnknownCurrency.new('currency not found') if currency.nil?
  currency
end