Class: SportsDataApi::Nfl::Season

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Season

Returns a new instance of Season.



6
7
8
9
10
11
# File 'lib/sports_data_api/nfl/season.rb', line 6

def initialize(json)
  @json = json
  @id = json['id']
  @year = json['year']
  @type = json['type'].to_sym
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

#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

Instance Method Details

#weeksObject



13
14
15
16
17
# File 'lib/sports_data_api/nfl/season.rb', line 13

def weeks
  @weeks ||= json.fetch('weeks', []).map do |week|
    Week.new(week, year, type)
  end
end