Class: Flashboy::Trade

Inherits:
Object
  • Object
show all
Defined in:
lib/flashboy/trade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#amountObject (readonly)

Returns the value of attribute amount.



3
4
5
# File 'lib/flashboy/trade.rb', line 3

def amount
  @amount
end

#exchangeObject (readonly)

Returns the value of attribute exchange.



3
4
5
# File 'lib/flashboy/trade.rb', line 3

def exchange
  @exchange
end

#executed_atObject (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_idObject (readonly)

Returns the value of attribute global_id.



3
4
5
# File 'lib/flashboy/trade.rb', line 3

def global_id
  @global_id
end

#pairObject (readonly)

Returns the value of attribute pair.



3
4
5
# File 'lib/flashboy/trade.rb', line 3

def pair
  @pair
end

#priceObject (readonly)

Returns the value of attribute price.



3
4
5
# File 'lib/flashboy/trade.rb', line 3

def price
  @price
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/flashboy/trade.rb', line 3

def type
  @type
end

Instance Method Details

#idObject



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