Class: Options::Strategies::OptionType
- Inherits:
-
Object
- Object
- Options::Strategies::OptionType
- Defined in:
- lib/options/strategies/option_type.rb
Instance Attribute Summary collapse
-
#default_units ⇒ Object
readonly
Returns the value of attribute default_units.
-
#execute_units ⇒ Object
readonly
Returns the value of attribute execute_units.
-
#expiry_date ⇒ Object
Returns the value of attribute expiry_date.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
-
#ltp ⇒ Object
Returns the value of attribute ltp.
-
#size ⇒ Object
Returns the value of attribute size.
-
#strike_price ⇒ Object
readonly
Returns the value of attribute strike_price.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ OptionType
constructor
A new instance of OptionType.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ OptionType
Returns a new instance of OptionType.
12 13 14 15 16 |
# File 'lib/options/strategies/option_type.rb', line 12 def initialize(={}) @strike_price = [:strike_price] @index_name = [:index_name] @default_units = eval("IndexUnits::#{@index_name}") end |
Instance Attribute Details
#default_units ⇒ Object (readonly)
Returns the value of attribute default_units.
10 11 12 |
# File 'lib/options/strategies/option_type.rb', line 10 def default_units @default_units end |
#execute_units ⇒ Object (readonly)
Returns the value of attribute execute_units.
10 11 12 |
# File 'lib/options/strategies/option_type.rb', line 10 def execute_units @execute_units end |
#expiry_date ⇒ Object
Returns the value of attribute expiry_date.
10 11 12 |
# File 'lib/options/strategies/option_type.rb', line 10 def expiry_date @expiry_date end |
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name.
10 11 12 |
# File 'lib/options/strategies/option_type.rb', line 10 def index_name @index_name end |
#ltp ⇒ Object
Returns the value of attribute ltp.
10 11 12 |
# File 'lib/options/strategies/option_type.rb', line 10 def ltp @ltp end |
#size ⇒ Object
Returns the value of attribute size.
10 11 12 |
# File 'lib/options/strategies/option_type.rb', line 10 def size @size end |
#strike_price ⇒ Object (readonly)
Returns the value of attribute strike_price.
10 11 12 |
# File 'lib/options/strategies/option_type.rb', line 10 def strike_price @strike_price end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/options/strategies/option_type.rb', line 10 def type @type end |
Instance Method Details
#to_hash ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/options/strategies/option_type.rb', line 35 def to_hash hash = {}.tap do |hash| self.instance_variables.each do |var| variable = var.to_s.tr('@', '') hash[variable] = instance_variable_get("@#{variable}") end hash["option_type"] = self.class.name.split('::').last end end |
#to_json ⇒ Object
45 46 47 |
# File 'lib/options/strategies/option_type.rb', line 45 def to_json to_hash.to_json end |