Class: Coinone::Public::Tickers

Inherits:
Object
  • Object
show all
Defined in:
lib/coinone/public/tickers.rb,
lib/coinone/public/tickers/ticker.rb

Defined Under Namespace

Classes: Ticker

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Tickers

Returns a new instance of Tickers.



9
10
11
12
13
14
# File 'lib/coinone/public/tickers.rb', line 9

def initialize(params={})
  @result = params[:result] || nil
  @timestamp = params[:timestamp] || nil
  @tickers = []
  push_tickers(params)
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



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

def result
  @result
end

#tickersObject (readonly)

Returns the value of attribute tickers.



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

def tickers
  @tickers
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



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

def timestamp
  @timestamp
end

Instance Method Details

#push_tickers(params) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/coinone/public/tickers.rb', line 16

def push_tickers(params)
  @tickers.clear
  currency_list = [:btc, :eth, :etc]
  currency_list.each do |currency|
    if params.has_key? currency
      @tickers.push(Ticker.new(params[currency]))
    end
  end
  @tickers.push(Ticker.new(params)) if params.has_key? :currency
end