Class: BitcoinAverage::Ticker
- Inherits:
-
Object
- Object
- BitcoinAverage::Ticker
- Includes:
- Requester
- Defined in:
- lib/bitcoinaverage/ticker.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ask ⇒ Object
Returns the value of attribute ask.
-
#avg_24h ⇒ Object
Returns the value of attribute avg_24h.
-
#bid ⇒ Object
Returns the value of attribute bid.
-
#last ⇒ Object
Returns the value of attribute last.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
Methods included from Requester
#available_currencies, #get, #known_currency?
Instance Attribute Details
#ask ⇒ Object
Returns the value of attribute ask.
7 8 9 |
# File 'lib/bitcoinaverage/ticker.rb', line 7 def ask @ask end |
#avg_24h ⇒ Object
Returns the value of attribute avg_24h.
7 8 9 |
# File 'lib/bitcoinaverage/ticker.rb', line 7 def avg_24h @avg_24h end |
#bid ⇒ Object
Returns the value of attribute bid.
7 8 9 |
# File 'lib/bitcoinaverage/ticker.rb', line 7 def bid @bid end |
#last ⇒ Object
Returns the value of attribute last.
7 8 9 |
# File 'lib/bitcoinaverage/ticker.rb', line 7 def last @last end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/bitcoinaverage/ticker.rb', line 7 def @timestamp end |
Instance Method Details
#request_info(currency = 'USD') ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# 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 |