module Fafx::ExchangeRate

Public Class Methods

at(date, base, other) click to toggle source
# 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_available() click to toggle source
# File lib/fafx/exchange_rate.rb, line 16
def currencies_available
  Core.new.currencies
end
dates_available() click to toggle source
# File lib/fafx/exchange_rate.rb, line 20
def dates_available
  Core.new.dates
end
get(base, other) click to toggle source
# File lib/fafx/exchange_rate.rb, line 3
def get(base, other)
  core = Core.new
  core.rate(other) / core.rate(base)
end
most_recent() click to toggle source
# 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_data() click to toggle source
# File lib/fafx/exchange_rate.rb, line 30
def update_data
  DataFetcher.save_to_disk
end

Private Instance Methods

at(date, base, other) click to toggle source
# 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_available() click to toggle source
# File lib/fafx/exchange_rate.rb, line 16
def currencies_available
  Core.new.currencies
end
dates_available() click to toggle source
# File lib/fafx/exchange_rate.rb, line 20
def dates_available
  Core.new.dates
end
get(base, other) click to toggle source
# File lib/fafx/exchange_rate.rb, line 3
def get(base, other)
  core = Core.new
  core.rate(other) / core.rate(base)
end
most_recent() click to toggle source
# 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_data() click to toggle source
# File lib/fafx/exchange_rate.rb, line 30
def update_data
  DataFetcher.save_to_disk
end