Class: Sportradar::Nfl::LeagueSchedule
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize
Methods inherited from ApiRequest
#client, #endpoint, fetch, #league, #save, save
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
#fetch ⇒ Object
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
|
#path ⇒ Object
28
29
30
|
# File 'lib/sportradar/nfl/league_schedule.rb', line 28
def path
"#{year}/#{interval_type}/schedule.json"
end
|