Class: Market::Quote

Inherits:
Object
  • Object
show all
Includes:
ArgumentProcessor
Defined in:
lib/market.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ArgumentProcessor

#process_args

Constructor Details

#initialize(args = {}) ⇒ Quote

Returns a new instance of Quote.



30
31
32
33
# File 'lib/market.rb', line 30

def initialize(args = {})
  process_args(args)
  self.extra = {}
end

Instance Attribute Details

#askObject

Returns the value of attribute ask.



28
29
30
# File 'lib/market.rb', line 28

def ask
  @ask
end

#bidObject

Returns the value of attribute bid.



28
29
30
# File 'lib/market.rb', line 28

def bid
  @bid
end

#extraObject

Returns the value of attribute extra.



28
29
30
# File 'lib/market.rb', line 28

def extra
  @extra
end

#lastObject

Returns the value of attribute last.



28
29
30
# File 'lib/market.rb', line 28

def last
  @last
end

#symbolObject

Returns the value of attribute symbol.



28
29
30
# File 'lib/market.rb', line 28

def symbol
  @symbol
end

Instance Method Details

#inspectObject



39
40
41
42
43
# File 'lib/market.rb', line 39

def inspect
  "<%s: L:%s B:%s A:%s>" % [
    symbol, last.to_money_s, bid.to_money_s, ask.to_money_s
  ]
end

#midObject



35
36
37
# File 'lib/market.rb', line 35

def mid
  @mid ||= [bid, ask].reduce(:+) / 2.0
end