Class: WavesRubyClient::OrderBook
- Inherits:
-
Object
- Object
- WavesRubyClient::OrderBook
- Defined in:
- lib/waves_ruby_client/order_book.rb
Overview
Orderbook for a pair of assets
Instance Attribute Summary collapse
-
#asks ⇒ Object
Returns the value of attribute asks.
-
#asset1 ⇒ Object
Returns the value of attribute asset1.
-
#asset2 ⇒ Object
Returns the value of attribute asset2.
-
#bids ⇒ Object
Returns the value of attribute bids.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(asset1, asset2) ⇒ OrderBook
constructor
A new instance of OrderBook.
- #refresh ⇒ Object
Constructor Details
#initialize(asset1, asset2) ⇒ OrderBook
Returns a new instance of OrderBook.
12 13 14 15 16 |
# File 'lib/waves_ruby_client/order_book.rb', line 12 def initialize(asset1, asset2) self.asset1 = asset1 self.asset2 = asset2 self.bids = self.asks = [] end |
Instance Attribute Details
#asks ⇒ Object
Returns the value of attribute asks.
10 11 12 |
# File 'lib/waves_ruby_client/order_book.rb', line 10 def asks @asks end |
#asset1 ⇒ Object
Returns the value of attribute asset1.
10 11 12 |
# File 'lib/waves_ruby_client/order_book.rb', line 10 def asset1 @asset1 end |
#asset2 ⇒ Object
Returns the value of attribute asset2.
10 11 12 |
# File 'lib/waves_ruby_client/order_book.rb', line 10 def asset2 @asset2 end |
#bids ⇒ Object
Returns the value of attribute bids.
10 11 12 |
# File 'lib/waves_ruby_client/order_book.rb', line 10 def bids @bids end |
Class Method Details
.btc_waves ⇒ Object
6 7 8 |
# File 'lib/waves_ruby_client/order_book.rb', line 6 def self.btc_waves new(WavesRubyClient::Asset.waves, WavesRubyClient::Asset.btc) end |
Instance Method Details
#refresh ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/waves_ruby_client/order_book.rb', line 18 def refresh order_book = WavesRubyClient::Api.instance.call_matcher( "/orderbook/#{asset1.url_id}/#{asset2.url_id}#getOrderBook" ) self.asks = order_book['asks'].map { |order| scale(order) } self.bids = order_book['bids'].map { |order| scale(order) } end |