Class: Bitstamper::Models::LiveTrade

Inherits:
Object
  • Object
show all
Defined in:
lib/bitstamper/models/live_trade.rb

Constant Summary collapse

TYPES =
{
  0 => :buy,
  1 => :sell
}
MAPPING =
{
  id:                             :string,
  buy_order_id:                   :string,
  sell_order_id:                  :string,
  amount:                         :float,
  amount_str:                     :string,
  price:                          :float,
  price_str:                      :string,
  epoch:                          :integer,
  timestamp:                      :time,
  type:                           :integer,
  product:                        :string,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ LiveTrade

Returns a new instance of LiveTrade.



29
30
31
32
33
34
35
36
37
# File 'lib/bitstamper/models/live_trade.rb', line 29

def initialize(hash)
  hash.each do |key, value|
    type      =     ::Bitstamper::Models::LiveTrade::MAPPING.fetch(key, nil)
    value     =     value && type ? ::Bitstamper::Utilities::convert_value(value, type) : value
    self.send("#{key}=", value) if self.respond_to?(key)
  end
  
  self.type   =   TYPES[self.type]
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/bitstamper/models/live_trade.rb', line 5

def amount
  @amount
end

#amount_strObject

Returns the value of attribute amount_str.



5
6
7
# File 'lib/bitstamper/models/live_trade.rb', line 5

def amount_str
  @amount_str
end

#buy_order_idObject

Returns the value of attribute buy_order_id.



4
5
6
# File 'lib/bitstamper/models/live_trade.rb', line 4

def buy_order_id
  @buy_order_id
end

#epochObject

Returns the value of attribute epoch.



6
7
8
# File 'lib/bitstamper/models/live_trade.rb', line 6

def epoch
  @epoch
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/bitstamper/models/live_trade.rb', line 4

def id
  @id
end

#priceObject

Returns the value of attribute price.



5
6
7
# File 'lib/bitstamper/models/live_trade.rb', line 5

def price
  @price
end

#price_strObject

Returns the value of attribute price_str.



5
6
7
# File 'lib/bitstamper/models/live_trade.rb', line 5

def price_str
  @price_str
end

#productObject

Returns the value of attribute product.



8
9
10
# File 'lib/bitstamper/models/live_trade.rb', line 8

def product
  @product
end

#sell_order_idObject

Returns the value of attribute sell_order_id.



4
5
6
# File 'lib/bitstamper/models/live_trade.rb', line 4

def sell_order_id
  @sell_order_id
end

#timestampObject

Returns the value of attribute timestamp.



6
7
8
# File 'lib/bitstamper/models/live_trade.rb', line 6

def timestamp
  @timestamp
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/bitstamper/models/live_trade.rb', line 7

def type
  @type
end