Class: BudaApi::Models::Trades

Inherits:
BaseModel show all
Defined in:
lib/buda_api/models.rb

Overview

Trades collection model

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#raw, #to_h, #to_json

Constructor Details

#initialize(data) ⇒ Trades

Returns a new instance of Trades.



166
167
168
169
170
# File 'lib/buda_api/models.rb', line 166

def initialize(data)
  super(data) 
  @trades = (data["trades"] || []).map { |trade_data| Trade.new(trade_data) }
  @last_timestamp = data["last_timestamp"]
end

Instance Attribute Details

#last_timestamp ⇒ Object (readonly)

Returns the value of attribute last_timestamp.



172
173
174
# File 'lib/buda_api/models.rb', line 172

def last_timestamp
  @last_timestamp
end

#trades ⇒ Object (readonly)

Returns the value of attribute trades.



172
173
174
# File 'lib/buda_api/models.rb', line 172

def trades
  @trades
end

Instance Method Details

#count ⇒ Object



174
175
176
# File 'lib/buda_api/models.rb', line 174

def count
  @trades.length
end

#each(&block) ⇒ Object



178
179
180
# File 'lib/buda_api/models.rb', line 178

def each(&block)
  @trades.each(&block)
end