class BitcoinAverage::Ticker

Attributes

ask[RW]
avg_24h[RW]
bid[RW]
last[RW]
timestamp[RW]

Public Instance Methods

request_info(currency = 'USD') click to toggle source
# File lib/bitcoinaverage/ticker.rb, line 9
def request_info(currency = 'USD')
  response = get(avg_type, currency)
  if response.success?
    # Small patch since an attribute can't be named "24h_avg"
    response = JSON.load(response.to_s) unless response.is_a?(Hash)
    self.avg_24h = response['24h_avg']
    response.delete('24h_avg')
    response.each do |key, value|
      send("#{key}=", value)
    end
    self
  else
    fail 'Error receiving response' # TODO: extended
  end
end