Class: OptionQuote
- Inherits:
-
Object
- Object
- OptionQuote
- Defined in:
- lib/options-lib/option_quote.rb
Instance Attribute Summary collapse
-
#ask ⇒ Object
readonly
Returns the value of attribute ask.
-
#bid ⇒ Object
readonly
Returns the value of attribute bid.
-
#option ⇒ Object
readonly
Returns the value of attribute option.
-
#stock_price ⇒ Object
readonly
Returns the value of attribute stock_price.
Instance Method Summary collapse
-
#initialize(option, args) ⇒ OptionQuote
constructor
A new instance of OptionQuote.
- #spread ⇒ Object
- #to_s ⇒ Object
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
#ask ⇒ Object (readonly)
Returns the value of attribute ask.
5 6 7 |
# File 'lib/options-lib/option_quote.rb', line 5 def ask @ask end |
#bid ⇒ Object (readonly)
Returns the value of attribute bid.
5 6 7 |
# File 'lib/options-lib/option_quote.rb', line 5 def bid @bid end |
#option ⇒ Object (readonly)
Returns the value of attribute option.
5 6 7 |
# File 'lib/options-lib/option_quote.rb', line 5 def option @option end |
#stock_price ⇒ Object (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
#spread ⇒ Object
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_s ⇒ Object
22 23 24 |
# File 'lib/options-lib/option_quote.rb', line 22 def to_s "#{option}: bid => #{bid}, ask => #{ask}" end |