Class: SportsDataApi::Nfl::Season

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_data_api/nfl/season.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/sports_data_api/nfl/season.rb', line 4

def type
  @type
end

#weeksObject (readonly)

Returns the value of attribute weeks.



4
5
6
# File 'lib/sports_data_api/nfl/season.rb', line 4

def weeks
  @weeks
end

#yearObject (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

Returns:

  • (Boolean)


20
21
22
# File 'lib/sports_data_api/nfl/season.rb', line 20

def self.valid?(season)
  [:PRE, :REG, :PST].include?(season)
end