Class: Bitstamper::Models::LiveTrade
- Inherits:
-
Object
- Object
- Bitstamper::Models::LiveTrade
- 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
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#amount_str ⇒ Object
Returns the value of attribute amount_str.
-
#buy_order_id ⇒ Object
Returns the value of attribute buy_order_id.
-
#epoch ⇒ Object
Returns the value of attribute epoch.
-
#id ⇒ Object
Returns the value of attribute id.
-
#price ⇒ Object
Returns the value of attribute price.
-
#price_str ⇒ Object
Returns the value of attribute price_str.
-
#product ⇒ Object
Returns the value of attribute product.
-
#sell_order_id ⇒ Object
Returns the value of attribute sell_order_id.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(hash) ⇒ LiveTrade
constructor
A new instance of LiveTrade.
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
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/bitstamper/models/live_trade.rb', line 5 def amount @amount end |
#amount_str ⇒ Object
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_id ⇒ Object
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 |
#epoch ⇒ Object
Returns the value of attribute epoch.
6 7 8 |
# File 'lib/bitstamper/models/live_trade.rb', line 6 def epoch @epoch end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/bitstamper/models/live_trade.rb', line 4 def id @id end |
#price ⇒ Object
Returns the value of attribute price.
5 6 7 |
# File 'lib/bitstamper/models/live_trade.rb', line 5 def price @price end |
#price_str ⇒ Object
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 |
#product ⇒ Object
Returns the value of attribute product.
8 9 10 |
# File 'lib/bitstamper/models/live_trade.rb', line 8 def product @product end |
#sell_order_id ⇒ Object
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 |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/bitstamper/models/live_trade.rb', line 6 def @timestamp end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/bitstamper/models/live_trade.rb', line 7 def type @type end |