class CoinSync::PriceLoaders::Cryptowatch
Public Class Methods
new(options)
click to toggle source
Calls superclass method
CoinSync::PriceLoaders::Base::new
# File lib/coinsync/price_loaders/cryptowatch.rb, line 9 def initialize(options) options.currency = options.currency&.upcase || 'USD' options.exchange ||= 'bitfinex' super Utils.lazy_require(self, 'cointools') @cryptowatch ||= CoinTools::Cryptowatch.new end
Public Instance Methods
cache_name()
click to toggle source
# File lib/coinsync/price_loaders/cryptowatch.rb, line 20 def cache_name "cryptowatch-#{@options.exchange}-#{@options.currency.downcase}" end
currency()
click to toggle source
# File lib/coinsync/price_loaders/cryptowatch.rb, line 24 def currency FiatCurrency.new(@options.currency) end
fetch_price(coin, time)
click to toggle source
# File lib/coinsync/price_loaders/cryptowatch.rb, line 28 def fetch_price(coin, time) result = @cryptowatch.get_price_fast(@options.exchange, coin.code.downcase + @options.currency.downcase, time) [result.price, result.time.to_i] end