Class: Coinone::Public::Orderbook

Inherits:
Object
  • Object
show all
Defined in:
lib/coinone/public/orderbook.rb,
lib/coinone/public/orderbook/order.rb

Defined Under Namespace

Classes: Order

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Orderbook

Returns a new instance of Orderbook.



9
10
11
12
13
14
15
16
17
# File 'lib/coinone/public/orderbook.rb', line 9

def initialize(params={})
  @result = params[:result] || nil
  @ask = []
  @bid = []
  @timestamp = params[:timestamp].to_i || nil
  @currency= params[:currency] || nil
  push_orders(params[:ask], @ask) if params.has_key? :ask
  push_orders(params[:bid], @bid) if params.has_key? :bid
end

Instance Attribute Details

#askObject (readonly)

Returns the value of attribute ask.



7
8
9
# File 'lib/coinone/public/orderbook.rb', line 7

def ask
  @ask
end

#bidObject (readonly)

Returns the value of attribute bid.



7
8
9
# File 'lib/coinone/public/orderbook.rb', line 7

def bid
  @bid
end

#currencyObject (readonly)

Returns the value of attribute currency.



7
8
9
# File 'lib/coinone/public/orderbook.rb', line 7

def currency
  @currency
end

#resultObject (readonly)

Returns the value of attribute result.



6
7
8
# File 'lib/coinone/public/orderbook.rb', line 6

def result
  @result
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



7
8
9
# File 'lib/coinone/public/orderbook.rb', line 7

def timestamp
  @timestamp
end

Instance Method Details

#push_orders(params, orders) ⇒ Object



19
20
21
22
23
24
# File 'lib/coinone/public/orderbook.rb', line 19

def push_orders(params, orders)
  orders.clear
  params.each do |order|
    orders.push(Order.new(order))
  end
end