Class: SchwabRb::DataObjects::MarketHours::SessionHours

Inherits:
Object
  • Object
show all
Defined in:
lib/schwab_rb/data_objects/market_hours.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_marketObject (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_marketObject (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_marketObject (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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_hObject



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