Class: OptionQuote

Inherits:
Object
  • Object
show all
Defined in:
lib/options-lib/option_quote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(option, args) ⇒ OptionQuote

Returns a new instance of OptionQuote.



7
8
9
10
11
12
# File 'lib/options-lib/option_quote.rb', line 7

def initialize(option, args)
  @option = option
  @bid = args[:bid] || nil
  @ask = args[:ask] || nil
  @stock_price = args[:stock_price] || nil
end

Instance Attribute Details

#askObject (readonly)

Returns the value of attribute ask.



5
6
7
# File 'lib/options-lib/option_quote.rb', line 5

def ask
  @ask
end

#bidObject (readonly)

Returns the value of attribute bid.



5
6
7
# File 'lib/options-lib/option_quote.rb', line 5

def bid
  @bid
end

#optionObject (readonly)

Returns the value of attribute option.



5
6
7
# File 'lib/options-lib/option_quote.rb', line 5

def option
  @option
end

#stock_priceObject (readonly)

Returns the value of attribute stock_price.



5
6
7
# File 'lib/options-lib/option_quote.rb', line 5

def stock_price
  @stock_price
end

Instance Method Details

#spreadObject



14
15
16
17
18
19
20
# File 'lib/options-lib/option_quote.rb', line 14

def spread
  if @bid and @ask
    (@ask - @bid).prettify.to_f
  else
    nil
  end
end

#to_sObject



22
23
24
# File 'lib/options-lib/option_quote.rb', line 22

def to_s
   "#{option}: bid => #{bid}, ask => #{ask}"
end