Class: Sportradar::Api::Football::Ncaafb
- Inherits:
-
Data
- Object
- Data
- Sportradar::Api::Football::Ncaafb
show all
- Defined in:
- lib/sportradar/api/football/ncaafb.rb,
lib/sportradar/api/football/ncaafb/api.rb,
lib/sportradar/api/football/ncaafb/game.rb,
lib/sportradar/api/football/ncaafb/play.rb,
lib/sportradar/api/football/ncaafb/team.rb,
lib/sportradar/api/football/ncaafb/week.rb,
lib/sportradar/api/football/ncaafb/drive.rb,
lib/sportradar/api/football/ncaafb/player.rb,
lib/sportradar/api/football/ncaafb/quarter.rb,
lib/sportradar/api/football/ncaafb/division.rb,
lib/sportradar/api/football/ncaafb/conference.rb,
lib/sportradar/api/football/ncaafb/subdivision.rb
Defined Under Namespace
Classes: Api, Conference, Division, Drive, Game, Play, Player, Quarter, Subdivision, Team, Week
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Data
#attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data
Constructor Details
#initialize(data = {}, **opts) ⇒ Ncaafb
Returns a new instance of Ncaafb.
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 10
def initialize(data = {}, **opts)
@api = opts[:api]
@id = data['id']
@season = opts[:year]
@type = opts[:type]
@divisions_hash = {}
@weeks_hash = {}
@games_hash = {}
@teams_hash = {}
end
|
Instance Attribute Details
#alias ⇒ Object
Returns the value of attribute alias.
5
6
7
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 5
def alias
@alias
end
|
#id ⇒ Object
Returns the value of attribute id.
5
6
7
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 5
def id
@id
end
|
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 5
def name
@name
end
|
#response ⇒ Object
Returns the value of attribute response.
5
6
7
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 5
def response
@response
end
|
#type ⇒ Object
Returns the value of attribute type.
5
6
7
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 5
def type
@type
end
|
Class Method Details
.sim_api ⇒ Object
def queue_venues
url, , options, timeout = api.get_request_info(path_venues)
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_venues)}
end
.simulation ⇒ Object
250
251
252
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 250
def self.simulation
new({}, api: sim_api, year: 2015, type: 'reg')
end
|
.simulations ⇒ Object
253
254
255
256
257
258
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 253
def self.simulations
api = sim_api
['2015/REG/1/WKY/MSH', '2015/REG/1/KEN/FLA', '2015/REG/1/WOU/PRST'].map do |game_uri|
Game.new({'id' => game_uri}).sim!
end
end
|
Instance Method Details
#all_attributes ⇒ Object
6
7
8
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 6
def all_attributes
[:name, :alias, :leagues, :divisions, :teams]
end
|
#conferences ⇒ Object
62
63
64
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 62
def conferences
divisions.flat_map(&:conferences)
end
|
#default_date ⇒ Object
110
111
112
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 110
def default_date
Date.today
end
|
#default_season ⇒ Object
113
114
115
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 113
def default_season
'reg'
end
|
#default_year ⇒ Object
107
108
109
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 107
def default_year
(Date.today - 60).year
end
|
#division(code_name) ⇒ Object
56
57
58
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 56
def division(code_name)
divisions_by_name[code_name]
end
|
#divisions ⇒ Object
53
54
55
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 53
def divisions
@divisions_hash.values
end
|
#games ⇒ Object
81
82
83
84
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 81
def games
get_schedule if @weeks_hash.empty?
weeks.flat_map(&:games)
end
|
#get_depth_charts ⇒ Object
198
199
200
201
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 198
def get_depth_charts
data = api.get_data(path_depth_charts).to_h
ingest_depth_charts(data)
end
|
#get_hierarchy(division = 'FBS') ⇒ Object
182
183
184
185
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 182
def get_hierarchy(division = 'FBS')
data = api.get_data(path_hierarchy(division)).to_h
ingest_hierarchy(data)
end
|
#get_schedule ⇒ Object
149
150
151
152
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 149
def get_schedule
data = api.get_data(path_schedule).to_h
ingest_schedule(data)
end
|
#get_standings(division = 'FBS') ⇒ Object
214
215
216
217
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 214
def get_standings(division = 'FBS')
data = api.get_data(path_standings(division)).to_h
ingest_standings(data)
end
|
#get_weekly_schedule(ncaafb_season_week = 1) ⇒ Object
165
166
167
168
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 165
def get_weekly_schedule(ncaafb_season_week = 1)
data = api.get_data(path_weekly_schedule(ncaafb_season_week)).to_h
ingest_weekly_schedule(data)
end
|
#hierarchy ⇒ Object
76
77
78
79
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 76
def hierarchy
get_hierarchy if divisions.empty?
self
end
|
#ingest_depth_charts(data) ⇒ Object
203
204
205
206
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 203
def ingest_depth_charts(data)
update(data, source: :teams)
data
end
|
#ingest_hierarchy(data) ⇒ Object
187
188
189
190
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 187
def ingest_hierarchy(data)
create_data(@divisions_hash, data, klass: Division, hierarchy: self, api: api)
data
end
|
#ingest_schedule(data) ⇒ Object
154
155
156
157
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 154
def ingest_schedule(data)
update(data, source: :weeks)
data
end
|
#ingest_standings(data) ⇒ Object
219
220
221
222
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 219
def ingest_standings(data)
update(data, source: :teams)
data
end
|
#ingest_weekly_schedule(data) ⇒ Object
170
171
172
173
174
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 170
def ingest_weekly_schedule(data)
create_data(@weeks_hash, data, klass: Week, hierarchy: self, api: api)
data
end
|
#ncaafb_season ⇒ Object
Also known as:
season
120
121
122
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 120
def ncaafb_season
@type || default_season
end
|
#path_base ⇒ Object
127
128
129
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 127
def path_base
"league"
end
|
#path_hierarchy(division = 'FBS') ⇒ Object
130
131
132
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 130
def path_hierarchy(division = 'FBS')
"teams/#{division}/hierarchy"
end
|
#path_rankings(ncaafb_season_week, poll_name = 'AP25') ⇒ Object
139
140
141
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 139
def path_rankings(ncaafb_season_week, poll_name = 'AP25')
"polls/#{poll_name}/#{season_year}/#{ncaafb_season_week}/rankings"
end
|
#path_schedule ⇒ Object
133
134
135
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 133
def path_schedule
"#{season_year}/#{ncaafb_season}/schedule"
end
|
#path_standings(division = 'FBS') ⇒ Object
142
143
144
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 142
def path_standings(division = 'FBS')
"teams/#{division}/#{season_year}/#{ncaafb_season}/standings"
end
|
#path_weekly_schedule(ncaafb_season_week) ⇒ Object
136
137
138
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 136
def path_weekly_schedule(ncaafb_season_week)
"#{season_year}/#{ncaafb_season}/#{ncaafb_season_week}/schedule"
end
|
#queue_depth_charts ⇒ Object
208
209
210
211
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 208
def queue_depth_charts
url, , options, timeout = api.get_request_info(path_depth_charts)
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_depth_charts)}
end
|
#queue_hierarchy ⇒ Object
192
193
194
195
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 192
def queue_hierarchy
url, , options, timeout = api.get_request_info(path_hierarchy)
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_hierarchy)}
end
|
#queue_schedule ⇒ Object
159
160
161
162
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 159
def queue_schedule
url, , options, timeout = api.get_request_info(path_schedule)
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_schedule)}
end
|
#queue_standings ⇒ Object
224
225
226
227
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 224
def queue_standings
url, , options, timeout = api.get_request_info(path_standings)
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_standings)}
end
|
#queue_weekly_schedule(ncaafb_season_week = 1) ⇒ Object
176
177
178
179
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 176
def queue_weekly_schedule(ncaafb_season_week = 1)
url, , options, timeout = api.get_request_info(path_weekly_schedule(ncaafb_season_week))
{url: url, headers: , params: options, timeout: timeout, callback: method(:ingest_weekly_schedule)}
end
|
#schedule ⇒ Object
66
67
68
69
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 66
def schedule
get_schedule if games.empty?
self
end
|
#season_year ⇒ Object
Also known as:
year
116
117
118
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 116
def season_year
@season || default_year
end
|
#standings ⇒ Object
71
72
73
74
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 71
def standings
get_standings if divisions.empty? || teams.first&.record.nil?
self
end
|
#team(team_id) ⇒ Object
98
99
100
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 98
def team(team_id)
teams.detect { |team| team.id == team_id }
end
|
#teams ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 85
def teams
teams = conferences.flat_map(&:teams)
if teams.empty?
if @teams_hash.empty?
get_hierarchy
conferences.flat_map(&:teams)
else
@teams_hash.values
end
else
teams
end
end
|
#update(data, source: nil, **opts) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 24
def update(data, source: nil, **opts)
@id = data['id'] if data['id']
@season = data['season'] if data['season']
@type = data['type'] if data['type']
create_data(@divisions_hash, data['divisions'], klass: Division, hierarchy: self, api: api) if data['divisions']
create_data(@divisions_hash, data['division'], klass: Division, hierarchy: self, api: api) if data['division']
create_data(@teams_hash, data['teams'], klass: Team, hierarchy: self, api: api) if data['teams']
if data['weeks']
create_data(@weeks_hash, data['weeks'], klass: Week, hierarchy: self, api: @api)
end
if data['games']
if data['games'].first.keys == ['game']
data['games'].map! { |hash| hash['game'] }
end
@games_hash = create_data(@games_hash, data['games'], klass: Game, hierarchy: self, api: api)
end
end
|
#weeks ⇒ Object
50
51
52
|
# File 'lib/sportradar/api/football/ncaafb.rb', line 50
def weeks
@weeks_hash.values
end
|