Class: SchwabRb::DataObjects::MarketHours::MarketInfo
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::MarketHours::MarketInfo
- Defined in:
- lib/schwab_rb/data_objects/market_hours.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#is_open ⇒ Object
readonly
Returns the value of attribute is_open.
-
#market_type ⇒ Object
readonly
Returns the value of attribute market_type.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#product_name ⇒ Object
readonly
Returns the value of attribute product_name.
-
#session_hours ⇒ Object
readonly
Returns the value of attribute session_hours.
Instance Method Summary collapse
- #bond? ⇒ Boolean
- #closed? ⇒ Boolean
- #date_object ⇒ Object
- #equity? ⇒ Boolean
- #forex? ⇒ Boolean
- #future? ⇒ Boolean
- #has_session_hours? ⇒ Boolean
-
#initialize(data) ⇒ MarketInfo
constructor
A new instance of MarketInfo.
- #open? ⇒ Boolean
- #option? ⇒ Boolean
- #post_market_hours ⇒ Object
- #pre_market_hours ⇒ Object
- #regular_market_hours ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ MarketInfo
Returns a new instance of MarketInfo.
125 126 127 128 129 130 131 132 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 125 def initialize(data) @date = data["date"] @market_type = data["marketType"] @product = data["product"] @product_name = data["productName"] @is_open = data["isOpen"] @session_hours = data["sessionHours"] ? SessionHours.new(data["sessionHours"]) : nil end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
123 124 125 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 123 def date @date end |
#is_open ⇒ Object (readonly)
Returns the value of attribute is_open.
123 124 125 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 123 def is_open @is_open end |
#market_type ⇒ Object (readonly)
Returns the value of attribute market_type.
123 124 125 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 123 def market_type @market_type end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
123 124 125 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 123 def product @product end |
#product_name ⇒ Object (readonly)
Returns the value of attribute product_name.
123 124 125 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 123 def product_name @product_name end |
#session_hours ⇒ Object (readonly)
Returns the value of attribute session_hours.
123 124 125 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 123 def session_hours @session_hours end |
Instance Method Details
#bond? ⇒ Boolean
196 197 198 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 196 def bond? @market_type == "BOND" end |
#closed? ⇒ Boolean
150 151 152 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 150 def closed? !open? end |
#date_object ⇒ Object
154 155 156 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 154 def date_object Date.parse(@date) if @date end |
#equity? ⇒ Boolean
180 181 182 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 180 def equity? @market_type == "EQUITY" end |
#forex? ⇒ Boolean
192 193 194 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 192 def forex? @market_type == "FOREX" end |
#future? ⇒ Boolean
188 189 190 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 188 def future? @market_type == "FUTURE" end |
#has_session_hours? ⇒ Boolean
158 159 160 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 158 def has_session_hours? !@session_hours.nil? end |
#open? ⇒ Boolean
146 147 148 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 146 def open? @is_open == true end |
#option? ⇒ Boolean
184 185 186 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 184 def option? @market_type == "OPTION" end |
#post_market_hours ⇒ Object
174 175 176 177 178 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 174 def post_market_hours return nil unless @session_hours @session_hours.post_market end |
#pre_market_hours ⇒ Object
168 169 170 171 172 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 168 def pre_market_hours return nil unless @session_hours @session_hours.pre_market end |
#regular_market_hours ⇒ Object
162 163 164 165 166 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 162 def regular_market_hours return nil unless @session_hours @session_hours.regular_market end |
#to_h ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 134 def to_h result = { "date" => @date, "marketType" => @market_type, "product" => @product, "isOpen" => @is_open } result["productName"] = @product_name if @product_name result["sessionHours"] = @session_hours.to_h if @session_hours result end |