Class: BTCT::TheRockAPI
- Inherits:
-
Object
- Object
- BTCT::TheRockAPI
- Defined in:
- lib/btct/therock.rb
Instance Method Summary collapse
Instance Method Details
#name ⇒ Object
7 8 9 |
# File 'lib/btct/therock.rb', line 7 def name "The Rock" end |
#ticker ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/btct/therock.rb', line 18 def ticker ticker = JSON.parse open("https://www.therocktrading.com/api/ticker/BTCUSD").read ticker = ticker["result"][0] Ticker.new( :last => ticker["last"].to_f, :volume => 0.0, :high => 0.0, :low => 0.0, :time => DateTime.now.new_offset(0), :exchange => name ) end |
#top ⇒ Object
11 12 13 14 15 16 |
# File 'lib/btct/therock.rb', line 11 def top ob = JSON.parse open("https://www.therocktrading.com/api/orderbook/BTCUSD").read bid = ob["bids"].sort { |x, y| x[0].to_f <=> y [0].to_f }.last ask = ob["asks"].sort { |x, y| x[0].to_f <=> y [0].to_f }.first return Quote.new(bid[0], bid[1], name), Quote.new(ask[0], ask[1], name) end |