Class: Bitcoin::Ticker
- Inherits:
-
Object
- Object
- Bitcoin::Ticker
- Defined in:
- lib/bitcoin/ticker.rb
Instance Attribute Summary collapse
-
#ask ⇒ Object
Returns the value of attribute ask.
-
#bid ⇒ Object
Returns the value of attribute bid.
-
#high ⇒ Object
Returns the value of attribute high.
-
#last ⇒ Object
Returns the value of attribute last.
-
#low ⇒ Object
Returns the value of attribute low.
-
#open ⇒ Object
Returns the value of attribute open.
-
#symbol ⇒ Object
Returns the value of attribute symbol.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#volume ⇒ Object
Returns the value of attribute volume.
-
#volumeQuote ⇒ Object
Returns the value of attribute volumeQuote.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#ask ⇒ Object
Returns the value of attribute ask.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def ask @ask end |
#bid ⇒ Object
Returns the value of attribute bid.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def bid @bid end |
#high ⇒ Object
Returns the value of attribute high.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def high @high end |
#last ⇒ Object
Returns the value of attribute last.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def last @last end |
#low ⇒ Object
Returns the value of attribute low.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def low @low end |
#open ⇒ Object
Returns the value of attribute open.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def open @open end |
#symbol ⇒ Object
Returns the value of attribute symbol.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def symbol @symbol end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def end |
#volume ⇒ Object
Returns the value of attribute volume.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def volume @volume end |
#volumeQuote ⇒ Object
Returns the value of attribute volumeQuote.
3 4 5 |
# File 'lib/bitcoin/ticker.rb', line 3 def volumeQuote @volumeQuote end |
Class Method Details
.all ⇒ Object
38 39 40 41 42 43 |
# File 'lib/bitcoin/ticker.rb', line 38 def self.all data = JSON.parse(RestClient.get("#{Bitcoin::BASE}/public/ticker")) data.map{ |ticker| Bitcoin::Ticker.new_from_object(ticker) } end |
.new_from_object(data) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bitcoin/ticker.rb', line 18 def self.new_from_object(data) t = Bitcoin::Ticker.new t.ask = data['ask'].to_f t.bid = data['bid'].to_f t.last = data['last'].to_f t.open = data['open'].to_f t.low = data['low'].to_f t.high = data['high'].to_f t.volume = data['volume'].to_f t.volumeQuote = data['volumeQuote'].to_f t. = Time.parse(data['timestamp']) t.symbol = data['symbol'] t end |
.new_from_symbol_name(symbol_name) ⇒ Object
33 34 35 36 |
# File 'lib/bitcoin/ticker.rb', line 33 def self.new_from_symbol_name(symbol_name) data = JSON.parse(RestClient.get("#{Bitcoin::BASE}/public/ticker/#{symbol_name}")) Bitcoin::Ticker.new_from_object(data) end |
Instance Method Details
#display_details ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bitcoin/ticker.rb', line 5 def display_details puts " \#{@symbol}\n Best Ask : \#{@ask.to_s.rjust(9)} || Best Bid: \#{@bid}\n Last Trade Price: \#{@last}\n Open: \#{@open}\n 24-Hour Low: \#{@low.to_s.rjust(9)} || 24-Hour High: \#{@high}\n Total 24-Hour Volume (Base): \#{@volume} (Quote): \#{@volumeQuote}\n \#{@timestamp}\n\n DOC\nend\n" |