Module: Fafx::ExchangeRate
- Defined in:
- lib/fafx/exchange_rate.rb
Class Method Summary collapse
- .at(date, base, other) ⇒ Object
- .currencies_available ⇒ Object
- .dates_available ⇒ Object
- .most_recent ⇒ Object
- .update_data ⇒ Object
Class Method Details
.at(date, base, other) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fafx/exchange_rate.rb', line 3 def at(date, base, other) case date.wday when 6 # Saturday date -= 1 when 0 # Sunday date -= 2 end ex_rates = Core.new base = ex_rates.rates_at(date.to_s, base) other = ex_rates.rates_at(date.to_s, other) other / base end |
.currencies_available ⇒ Object
17 18 19 |
# File 'lib/fafx/exchange_rate.rb', line 17 def currencies_available Core.new.currencies end |
.dates_available ⇒ Object
21 22 23 |
# File 'lib/fafx/exchange_rate.rb', line 21 def dates_available Core.new.dates end |
.most_recent ⇒ Object
25 26 27 28 29 |
# File 'lib/fafx/exchange_rate.rb', line 25 def most_recent ex_rates = Core.new first_date = ex_rates.dates.first ex_rates.rates[first_date] end |
.update_data ⇒ Object
31 32 33 |
# File 'lib/fafx/exchange_rate.rb', line 31 def update_data DataFetcher.save_to_disk end |