Module: FxFetcher::ClassMethods
- Defined in:
- lib/fx_fetcher.rb
Instance Method Summary collapse
- #at(date, base, counter) ⇒ Object
-
#currencies ⇒ Object
helper to create list of available currencies.
-
#valid_amount?(amount) ⇒ Boolean
helper to check if value is non text and greater than zero.
Instance Method Details
#at(date, base, counter) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/fx_fetcher.rb', line 9 def at(date, base, counter) if currency_present_for_date(date) search_for_rate(date, base, counter) else "No rates available for this date" end end |
#currencies ⇒ Object
helper to create list of available currencies
18 19 20 21 22 23 |
# File 'lib/fx_fetcher.rb', line 18 def currencies currencies = [] rates_for_date = self.where(rate_date: self.first.rate_date) rates_for_date.each { |rate| currencies << rate.counter_currency } currencies << rates_for_date.first.base_currency end |
#valid_amount?(amount) ⇒ Boolean
helper to check if value is non text and greater than zero
26 27 28 |
# File 'lib/fx_fetcher.rb', line 26 def valid_amount?(amount) amount.to_f > 0.0 end |