Class: MercadoBitcoin::Api::Data::OrderBook
- Inherits:
-
Object
- Object
- MercadoBitcoin::Api::Data::OrderBook
- Defined in:
- lib/mercado_bitcoin/api/data/order_book.rb
Instance Attribute Summary collapse
-
#asks ⇒ Object
Returns the value of attribute asks.
-
#bids ⇒ Object
Returns the value of attribute bids.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ OrderBook
constructor
A new instance of OrderBook.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ OrderBook
Returns a new instance of OrderBook.
6 7 8 9 |
# File 'lib/mercado_bitcoin/api/data/order_book.rb', line 6 def initialize(opts = {}) self.asks = opts[:asks] || opts['asks'] self.bids = opts[:bids] || opts['bids'] end |
Instance Attribute Details
#asks ⇒ Object
Returns the value of attribute asks.
4 5 6 |
# File 'lib/mercado_bitcoin/api/data/order_book.rb', line 4 def asks @asks end |
#bids ⇒ Object
Returns the value of attribute bids.
4 5 6 |
# File 'lib/mercado_bitcoin/api/data/order_book.rb', line 4 def bids @bids end |
Instance Method Details
#to_hash ⇒ Object
21 22 23 24 25 26 |
# File 'lib/mercado_bitcoin/api/data/order_book.rb', line 21 def to_hash { asks: asks.map { |i| i.to_hash }, bids: bids.map { |i| i.to_hash } } end |
#to_json ⇒ Object
28 29 30 |
# File 'lib/mercado_bitcoin/api/data/order_book.rb', line 28 def to_json to_hash.to_json end |