Module: Fafx::ExchangeRate

Defined in:
lib/fafx/exchange_rate.rb

Class Method Summary collapse

Class Method Details

.at(date, base, other) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/fafx/exchange_rate.rb', line 8

def at(date, base, other)
  date = DateHandler.get(date)
  ex_rates = Core.new
  base = ex_rates.rates_at(date, base)
  other = ex_rates.rates_at(date, other)
  other / base
end

.currencies_availableObject



16
17
18
# File 'lib/fafx/exchange_rate.rb', line 16

def currencies_available
  Core.new.currencies
end

.dates_availableObject



20
21
22
# File 'lib/fafx/exchange_rate.rb', line 20

def dates_available
  Core.new.dates
end

.get(base, other) ⇒ Object



3
4
5
6
# File 'lib/fafx/exchange_rate.rb', line 3

def get(base, other)
  core = Core.new
  core.rate(other) / core.rate(base)
end

.most_recentObject



24
25
26
27
28
# File 'lib/fafx/exchange_rate.rb', line 24

def most_recent
  ex_rates = Core.new
  first_date = ex_rates.dates.first
  ex_rates.rates[first_date]
end

.update_dataObject



30
31
32
# File 'lib/fafx/exchange_rate.rb', line 30

def update_data
  DataFetcher.save_to_disk
end