Class: SportsDataApi::Nfl::Season
- Inherits:
-
Object
- Object
- SportsDataApi::Nfl::Season
- Defined in:
- lib/sports_data_api/nfl/season.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#weeks ⇒ Object
readonly
Returns the value of attribute weeks.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
-
.valid?(season) ⇒ Boolean
Check if the requested season is a valid NFL season type.
Instance Method Summary collapse
-
#initialize(season_hash) ⇒ Season
constructor
A new instance of Season.
Constructor Details
#initialize(season_hash) ⇒ Season
Returns a new instance of Season.
6 7 8 9 10 11 12 13 |
# File 'lib/sports_data_api/nfl/season.rb', line 6 def initialize(season_hash) @weeks = [] @year = season_hash['season'] @type = season_hash['type'].to_sym @weeks = season_hash['weeks'].map do |week_hash| Week.new(@year, @type, week_hash) end end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/sports_data_api/nfl/season.rb', line 4 def type @type end |
#weeks ⇒ Object (readonly)
Returns the value of attribute weeks.
4 5 6 |
# File 'lib/sports_data_api/nfl/season.rb', line 4 def weeks @weeks end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/sports_data_api/nfl/season.rb', line 4 def year @year end |
Class Method Details
.valid?(season) ⇒ Boolean
Check if the requested season is a valid NFL season type.
The only valid types are: :PRE, :REG, :PST
20 21 22 |
# File 'lib/sports_data_api/nfl/season.rb', line 20 def self.valid?(season) [:PRE, :REG, :PST].include?(season) end |