Class: Exchange::ExternalAPI::Random
- Defined in:
- lib/exchange/external_api/random.rb
Overview
The Random API class, which is only intended for use in development mode. Returns random exchange rates.
Constant Summary collapse
- CURRENCIES =
Exchange::ISO.currencies
- RANDOM_RATES =
lambda { Hash[*CURRENCIES.map{|c| [c, rand] }.flatten] }
Instance Attribute Summary
Attributes inherited from Base
#base, #cache, #helper, #rates, #timestamp
Instance Method Summary collapse
-
#update(opts = {}) ⇒ Object
Updates the rates with new random ones The call gets cached for a maximum of 24 hours.
Methods inherited from Base
#convert, #initialize, #rate, #test_for_rates_and_raise_if_nil, #to_hash!
Constructor Details
This class inherits a constructor from Exchange::ExternalAPI::Base
Instance Method Details
#update(opts = {}) ⇒ Object
Updates the rates with new random ones The call gets cached for a maximum of 24 hours.
23 24 25 26 27 |
# File 'lib/exchange/external_api/random.rb', line 23 def update opts={} @base = :usd @rates = RANDOM_RATES.call @timestamp = Time.now.to_i end |