Class: SchwabRb::DataObjects::OptionExpirationChain::Expiration
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::OptionExpirationChain::Expiration
- Defined in:
- lib/schwab_rb/data_objects/option_expiration_chain.rb
Instance Attribute Summary collapse
-
#days_to_expiration ⇒ Object
readonly
Returns the value of attribute days_to_expiration.
-
#expiration_date ⇒ Object
readonly
Returns the value of attribute expiration_date.
-
#expiration_type ⇒ Object
readonly
Returns the value of attribute expiration_type.
-
#option_roots ⇒ Object
readonly
Returns the value of attribute option_roots.
-
#settlement_type ⇒ Object
readonly
Returns the value of attribute settlement_type.
-
#standard ⇒ Object
readonly
Returns the value of attribute standard.
Instance Method Summary collapse
- #date_object ⇒ Object
- #expires_in_days?(days) ⇒ Boolean
- #expires_today? ⇒ Boolean
- #expires_tomorrow? ⇒ Boolean
-
#initialize(data) ⇒ Expiration
constructor
A new instance of Expiration.
- #monthly? ⇒ Boolean
- #quarterly? ⇒ Boolean
- #special? ⇒ Boolean
- #standard? ⇒ Boolean
- #to_h ⇒ Object
- #weekly? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Expiration
Returns a new instance of Expiration.
85 86 87 88 89 90 91 92 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 85 def initialize(data) @expiration_date = fetch_value(data, "expirationDate") @days_to_expiration = fetch_value(data, "daysToExpiration") @expiration_type = fetch_value(data, "expirationType") @settlement_type = fetch_value(data, "settlementType") @option_roots = fetch_value(data, "optionRoots") @standard = fetch_value(data, "standard") end |
Instance Attribute Details
#days_to_expiration ⇒ Object (readonly)
Returns the value of attribute days_to_expiration.
82 83 84 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 82 def days_to_expiration @days_to_expiration end |
#expiration_date ⇒ Object (readonly)
Returns the value of attribute expiration_date.
82 83 84 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 82 def expiration_date @expiration_date end |
#expiration_type ⇒ Object (readonly)
Returns the value of attribute expiration_type.
82 83 84 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 82 def expiration_type @expiration_type end |
#option_roots ⇒ Object (readonly)
Returns the value of attribute option_roots.
82 83 84 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 82 def option_roots @option_roots end |
#settlement_type ⇒ Object (readonly)
Returns the value of attribute settlement_type.
82 83 84 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 82 def settlement_type @settlement_type end |
#standard ⇒ Object (readonly)
Returns the value of attribute standard.
82 83 84 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 82 def standard @standard end |
Instance Method Details
#date_object ⇒ Object
125 126 127 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 125 def date_object Date.parse(@expiration_date) if @expiration_date end |
#expires_in_days?(days) ⇒ Boolean
129 130 131 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 129 def expires_in_days?(days) @days_to_expiration == days end |
#expires_today? ⇒ Boolean
133 134 135 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 133 def expires_today? @days_to_expiration.zero? end |
#expires_tomorrow? ⇒ Boolean
137 138 139 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 137 def expires_tomorrow? @days_to_expiration == 1 end |
#monthly? ⇒ Boolean
113 114 115 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 113 def monthly? @expiration_type == "M" end |
#quarterly? ⇒ Boolean
117 118 119 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 117 def quarterly? @expiration_type == "Q" end |
#special? ⇒ Boolean
121 122 123 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 121 def special? @expiration_type == "S" end |
#standard? ⇒ Boolean
105 106 107 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 105 def standard? @standard == true end |
#to_h ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 94 def to_h { "expirationDate" => @expiration_date, "daysToExpiration" => @days_to_expiration, "expirationType" => @expiration_type, "settlementType" => @settlement_type, "optionRoots" => @option_roots, "standard" => @standard } end |
#weekly? ⇒ Boolean
109 110 111 |
# File 'lib/schwab_rb/data_objects/option_expiration_chain.rb', line 109 def weekly? @expiration_type == "W" end |