Class: Sportradar::Nfl::LeagueSchedule

Inherits:
Feeds::LeagueSchedule show all
Defined in:
lib/sportradar/nfl/league_schedule.rb

Direct Known Subclasses

WeeklySchedule

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Feeds::LeagueSchedule

#initialize

Methods inherited from ApiRequest

#client, #endpoint, fetch, #league, #save, save

Constructor Details

This class inherits a constructor from Sportradar::Feeds::LeagueSchedule

Class Method Details

.games(json:) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/sportradar/nfl/league_schedule.rb', line 18

def self.games(json:)
  [].tap do |games|
    (json['weeks'] || []).each do |week_json|
      (week_json['games'] || []).each do |game_json|
        games << game_json
      end
    end
  end
end

Instance Method Details

#fetchObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sportradar/nfl/league_schedule.rb', line 4

def fetch
  super.tap do |json|
    season = json['season']
    interval_type =  json['type']
    (json['weeks'] || []).each do |week_json|
      (week_json['games'] || []).each do |game_json|
        game_json['season'] = season
        game_json['interval_type'] = interval_type
        game_json['week'] = week_json['number']
      end
    end
  end
end

#pathObject



28
29
30
# File 'lib/sportradar/nfl/league_schedule.rb', line 28

def path
  "#{year}/#{interval_type}/schedule.json"
end