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.



24
25
26
27
# File 'lib/market.rb', line 24

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

Instance Attribute Details

#askObject

Returns the value of attribute ask.



22
23
24
# File 'lib/market.rb', line 22

def ask
  @ask
end

#bidObject

Returns the value of attribute bid.



22
23
24
# File 'lib/market.rb', line 22

def bid
  @bid
end

#extraObject

Returns the value of attribute extra.



22
23
24
# File 'lib/market.rb', line 22

def extra
  @extra
end

#lastObject

Returns the value of attribute last.



22
23
24
# File 'lib/market.rb', line 22

def last
  @last
end

#symbolObject

Returns the value of attribute symbol.



22
23
24
# File 'lib/market.rb', line 22

def symbol
  @symbol
end

Instance Method Details

#inspectObject



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

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

#midObject



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

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