Class: SchwabRb::DataObjects::MarketHours::SessionHours
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::MarketHours::SessionHours
- Defined in:
- lib/schwab_rb/data_objects/market_hours.rb
Instance Attribute Summary collapse
-
#post_market ⇒ Object
readonly
Returns the value of attribute post_market.
-
#pre_market ⇒ Object
readonly
Returns the value of attribute pre_market.
-
#regular_market ⇒ Object
readonly
Returns the value of attribute regular_market.
Instance Method Summary collapse
- #has_post_market? ⇒ Boolean
- #has_pre_market? ⇒ Boolean
- #has_regular_market? ⇒ Boolean
-
#initialize(data) ⇒ SessionHours
constructor
A new instance of SessionHours.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ SessionHours
Returns a new instance of SessionHours.
204 205 206 207 208 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 204 def initialize(data) @regular_market = parse_session_periods(data["regularMarket"]) @pre_market = parse_session_periods(data["preMarket"]) @post_market = parse_session_periods(data["postMarket"]) end |
Instance Attribute Details
#post_market ⇒ Object (readonly)
Returns the value of attribute post_market.
202 203 204 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 202 def post_market @post_market end |
#pre_market ⇒ Object (readonly)
Returns the value of attribute pre_market.
202 203 204 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 202 def pre_market @pre_market end |
#regular_market ⇒ Object (readonly)
Returns the value of attribute regular_market.
202 203 204 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 202 def regular_market @regular_market end |
Instance Method Details
#has_post_market? ⇒ Boolean
226 227 228 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 226 def has_post_market? @post_market && !@post_market.empty? end |
#has_pre_market? ⇒ Boolean
222 223 224 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 222 def has_pre_market? @pre_market && !@pre_market.empty? end |
#has_regular_market? ⇒ Boolean
218 219 220 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 218 def has_regular_market? @regular_market && !@regular_market.empty? end |
#to_h ⇒ Object
210 211 212 213 214 215 216 |
# File 'lib/schwab_rb/data_objects/market_hours.rb', line 210 def to_h result = {} result["regularMarket"] = @regular_market.map(&:to_h) if @regular_market result["preMarket"] = @pre_market.map(&:to_h) if @pre_market result["postMarket"] = @post_market.map(&:to_h) if @post_market result end |