Sha256: 0d373caea36202db0d73f058794a48eafd81dd3f27b1d1f7ffd3c140fdd5d3d4
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
# -*- encoding : utf-8 -*- module Exchange module ExternalAPI # The Random API class, which is only intended for use in development mode. Returns random exchange rates. # @author Beat Richartz # @version 1.0 # @since 1.0 # class Random < Base CURRENCIES = Exchange::ISO.currencies RANDOM_RATES = lambda { Hash[*CURRENCIES.zip(CURRENCIES.size.times.map{|i| rand}).flatten] } # Updates the rates with new random ones # The call gets cached for a maximum of 24 hours. # @version 0.7 # @param [Hash] opts Options to define for the API Call # @option opts [Time, String] :at a historical date to get the exchange rates for # @example Update the currency bot API to use the file of March 2, 2010 # Exchange::ExternalAPI::XavierMedia.new.update(:at => Time.gm(3,2,2010)) # def update(opts={}) @base = :usd @rates = RANDOM_RATES.call @timestamp = Time.now.to_i end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
exchange-1.0.4 | lib/exchange/external_api/random.rb |
exchange-1.0.2 | lib/exchange/external_api/random.rb |
exchange-1.0.0 | lib/exchange/external_api/random.rb |