Class: Flashboy::Trade
- Inherits:
-
Object
- Object
- Flashboy::Trade
- Defined in:
- lib/flashboy/trade.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
-
#executed_at ⇒ Object
readonly
Returns the value of attribute executed_at.
-
#global_id ⇒ Object
readonly
Returns the value of attribute global_id.
-
#pair ⇒ Object
readonly
Returns the value of attribute pair.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(attrs) ⇒ Trade
constructor
A new instance of Trade.
- #to_json(_opts) ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Trade
Returns a new instance of Trade.
5 6 7 8 9 10 11 12 13 |
# File 'lib/flashboy/trade.rb', line 5 def initialize(attrs) @global_id = attrs[:global_id] @type = attrs[:type] @exchange = attrs[:exchange] @pair = attrs[:pair] @price = attrs[:price].to_s.to_f @amount = attrs[:amount].to_s.to_f @executed_at = attrs[:executed_at] end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
3 4 5 |
# File 'lib/flashboy/trade.rb', line 3 def amount @amount end |
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
3 4 5 |
# File 'lib/flashboy/trade.rb', line 3 def exchange @exchange end |
#executed_at ⇒ Object (readonly)
Returns the value of attribute executed_at.
3 4 5 |
# File 'lib/flashboy/trade.rb', line 3 def executed_at @executed_at end |
#global_id ⇒ Object (readonly)
Returns the value of attribute global_id.
3 4 5 |
# File 'lib/flashboy/trade.rb', line 3 def global_id @global_id end |
#pair ⇒ Object (readonly)
Returns the value of attribute pair.
3 4 5 |
# File 'lib/flashboy/trade.rb', line 3 def pair @pair end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
3 4 5 |
# File 'lib/flashboy/trade.rb', line 3 def price @price end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/flashboy/trade.rb', line 3 def type @type end |
Instance Method Details
#id ⇒ Object
15 16 17 |
# File 'lib/flashboy/trade.rb', line 15 def id global_id.split('-').last end |
#to_json(_opts) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/flashboy/trade.rb', line 19 def to_json(_opts) { global_id: global_id, type: type, exchange: exchange, pair: pair, price: price, amount: amount, executed_at: executed_at }.to_json end |