Class: BTCT::TheRockAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/btct/therock.rb

Instance Method Summary collapse

Instance Method Details

#nameObject



7
8
9
# File 'lib/btct/therock.rb', line 7

def name
  "The Rock"
end

#topObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/btct/therock.rb', line 11

def top
  begin
    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)
  rescue
    return Quote.new(0.0, 0.0, name), Quote.new(0.0, 0.0, name)
  end
end