sportradar-api 0.11.29 → 0.11.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sportradar/api/football/game.rb +1 -1
- data/lib/sportradar/api/football/ncaafb/play.rb +2 -0
- data/lib/sportradar/api/football/play.rb +17 -5
- data/lib/sportradar/api/football/play_statistics.rb +94 -44
- data/lib/sportradar/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76ddfa31a38fdaeecf69e5185c005d42b696b39e
|
4
|
+
data.tar.gz: a6ae4ad2d9340c1b7e61fbfb2478541b983f7861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b955ecd7d861b43f7bea35bb1b31cc1b85e35dea5a3c24f46908554f9e6f8850674c5b99e89c23eb984763d5b5cd9fbf55ff3f7212ab6a3cf7db8319c9266d78
|
7
|
+
data.tar.gz: ef369787441c79cd2f5aeb2834b3e41d654bd9923a340efb56520cc3c45c18d5797b0ec09f89d97bd14eec57f5b1ad3d2d856b438ab28f0a58cb0995c3a3cc01
|
data/Gemfile.lock
CHANGED
@@ -43,18 +43,28 @@ module Sportradar
|
|
43
43
|
@participants = data["participants"] if data["participants"]
|
44
44
|
@play_type = data["play_type"] if data["play_type"]
|
45
45
|
@sequence = data["sequence"] if data["sequence"]
|
46
|
-
|
46
|
+
|
47
47
|
@deleted = data["deleted"] || @deleted
|
48
48
|
|
49
49
|
@details = data["details"].gsub('.json', '') if data["details"]
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
if data['statistics']
|
52
|
+
@statistics = Sportradar::Api::Football::PlayStatistics.new(data['statistics'])
|
53
|
+
elsif data['players']
|
54
|
+
@statistics = Sportradar::Api::Football::PlayStatistics.new(data['players'])
|
55
|
+
else
|
56
|
+
@statistics ||= OpenStruct.new(players: [])
|
57
|
+
end
|
58
|
+
parse_player
|
53
59
|
@wall_clock = data["wall_clock"]
|
54
60
|
|
55
61
|
self
|
56
62
|
end
|
57
63
|
|
64
|
+
def players
|
65
|
+
statistics.players
|
66
|
+
end
|
67
|
+
|
58
68
|
def deleted?
|
59
69
|
!!@deleted
|
60
70
|
end
|
@@ -94,11 +104,11 @@ module Sportradar
|
|
94
104
|
# check for fumble/interception
|
95
105
|
parse_description_for_drive_end
|
96
106
|
when 'punt'
|
97
|
-
|
107
|
+
parse_description_for_drive_end
|
98
108
|
when 'penalty'
|
99
109
|
nil
|
100
110
|
when 'fieldgoal'
|
101
|
-
|
111
|
+
parse_description_for_drive_end # nullified plays still have FG
|
102
112
|
when 'extrapoint'
|
103
113
|
:pat
|
104
114
|
else
|
@@ -108,6 +118,8 @@ module Sportradar
|
|
108
118
|
|
109
119
|
def parse_description_for_drive_end
|
110
120
|
parsed_ending = case @description
|
121
|
+
when /no play/i
|
122
|
+
nil
|
111
123
|
when /intercepted/i
|
112
124
|
:interception
|
113
125
|
when /fumbles/i
|
@@ -6,6 +6,15 @@ module Sportradar
|
|
6
6
|
def initialize(data)
|
7
7
|
data = [data] if data.is_a?(Hash)
|
8
8
|
@response = data
|
9
|
+
if data.first['name'] # indicates college data structures. we want to convert it to nfl data structures
|
10
|
+
data.map! do |hash|
|
11
|
+
type = self.class.college_type_translations.each_key.detect { |str| hash.key?(str) }
|
12
|
+
binding.pry if type.nil?
|
13
|
+
stats = hash.delete(type)
|
14
|
+
new_team = { 'id' => hash['team'], 'alias' => hash['team'] } # use intermediate variable to avoid temp memory blowup
|
15
|
+
new_hash = { 'player' => hash, 'team' => new_team, 'stat_type' => self.class.college_type_translations[type] }.merge(stats)
|
16
|
+
end
|
17
|
+
end
|
9
18
|
data.each do |hash|
|
10
19
|
var = instance_variable_get("@#{hash['stat_type']}")
|
11
20
|
unless var
|
@@ -27,6 +36,27 @@ module Sportradar
|
|
27
36
|
@players_by_team ||= players.group_by(&:team)
|
28
37
|
end
|
29
38
|
|
39
|
+
def self.college_type_translations
|
40
|
+
@college_type_translations ||= {
|
41
|
+
"kickoffs" => 'kick',
|
42
|
+
"kick_return" => 'return',
|
43
|
+
"rushing" => 'rush',
|
44
|
+
"fumble" => 'fumble',
|
45
|
+
"defense" => 'defense',
|
46
|
+
"receiving" => 'receive',
|
47
|
+
"punting" => 'punt',
|
48
|
+
"penalty" => 'penalty',
|
49
|
+
"passing" => 'pass',
|
50
|
+
"field_goal" => 'field_goal',
|
51
|
+
"extra_point" => 'extra_point',
|
52
|
+
"blocked_field_goal_return" => 'block',
|
53
|
+
"interception_return" => 'return',
|
54
|
+
"fumble_return" => 'return',
|
55
|
+
"punt_return" => 'return',
|
56
|
+
'misc' => 'misc',
|
57
|
+
}.freeze
|
58
|
+
end
|
59
|
+
|
30
60
|
def self.stat_type_classes
|
31
61
|
@stat_type_classes ||= {
|
32
62
|
'kick' => PlayKickStatistics,
|
@@ -52,7 +82,8 @@ module Sportradar
|
|
52
82
|
class MiscStatistics < Data
|
53
83
|
attr_reader :team, :player, :yards
|
54
84
|
def initialize(data)
|
55
|
-
@
|
85
|
+
@response = data
|
86
|
+
@yards = data['yards'] || data['yds']
|
56
87
|
@team = OpenStruct.new(data['team']) if data['team']
|
57
88
|
@player = OpenStruct.new(data['player']) if data['player']
|
58
89
|
end
|
@@ -61,8 +92,9 @@ module Sportradar
|
|
61
92
|
class BlockStatistics < Data
|
62
93
|
attr_reader :team, :player, :block, :category
|
63
94
|
def initialize(data)
|
95
|
+
@response = data
|
64
96
|
@category = data['category']
|
65
|
-
@block = data['block']
|
97
|
+
@block = data['block'] || data['blk']
|
66
98
|
@team = OpenStruct.new(data['team']) if data['team']
|
67
99
|
@player = OpenStruct.new(data['player']) if data['player']
|
68
100
|
end
|
@@ -71,6 +103,7 @@ module Sportradar
|
|
71
103
|
class PlayDownConversionStatistics < Data
|
72
104
|
attr_accessor :attempt, :complete, :down, :nullified, :team, :player
|
73
105
|
def initialize(data)
|
106
|
+
@response = data
|
74
107
|
@attempt = data['attempt']
|
75
108
|
@complete = data['complete']
|
76
109
|
@down = data['down']
|
@@ -87,6 +120,7 @@ module Sportradar
|
|
87
120
|
class PlayDefenseStatistics < Data
|
88
121
|
attr_accessor :ast_tackle, :interception, :int_yards, :nullified, :pass_defended, :primary, :qb_hit, :sack, :sack_yards, :tlost, :tlost_yards, :team, :player, :tackle, :int_touchdown
|
89
122
|
def initialize(data)
|
123
|
+
@response = data
|
90
124
|
@ast_tackle = data['ast_tackle']
|
91
125
|
@interception = data['interception']
|
92
126
|
@int_yards = data['int_yards']
|
@@ -113,6 +147,7 @@ module Sportradar
|
|
113
147
|
class PlayExtraPointStatistics < Data
|
114
148
|
attr_accessor :attempt, :nullified
|
115
149
|
def initialize(data)
|
150
|
+
@response = data
|
116
151
|
@attempt = data['attempt']
|
117
152
|
@nullified = data['nullified']
|
118
153
|
end
|
@@ -125,11 +160,13 @@ module Sportradar
|
|
125
160
|
class PlayFieldGoalStatistics < Data
|
126
161
|
attr_accessor :attempt, :att_yards, :missed, :yards, :nullified, :blocked, :team, :player
|
127
162
|
def initialize(data)
|
128
|
-
|
163
|
+
"att"=>1, "made"=>1, "yds"=>17, "att_yds"=>17, "blk"=>0, "ret"=>0}
|
164
|
+
@response = data
|
165
|
+
@attempt = data['attempt'] || data['att']
|
129
166
|
@att_yards = data['att_yards']
|
130
|
-
@missed = data['missed']
|
131
|
-
@blocked = data['blocked']
|
132
|
-
@yards = data['yards']
|
167
|
+
@missed = data['missed'] || (data['made'] - 1).abs
|
168
|
+
@blocked = data['blocked'] || data['blk']
|
169
|
+
@yards = data['yards'] || data['yds']
|
133
170
|
@nullified = data['nullified']
|
134
171
|
@team = OpenStruct.new(data['team']) if data['team']
|
135
172
|
@player = OpenStruct.new(data['player']) if data['player']
|
@@ -143,6 +180,7 @@ module Sportradar
|
|
143
180
|
class PlayFirstDownStatistics < Data
|
144
181
|
attr_accessor :category, :nullified, :team
|
145
182
|
def initialize(data)
|
183
|
+
@response = data
|
146
184
|
@category = data['category']
|
147
185
|
@team = OpenStruct.new(data['team']) if data['team']
|
148
186
|
@nullified = data['nullified']
|
@@ -156,17 +194,18 @@ module Sportradar
|
|
156
194
|
class PlayPassingStatistics < Data
|
157
195
|
attr_accessor :attempt, :att_yards, :complete, :firstdown, :goaltogo, :inside_20, :interception, :sack, :sack_yards, :touchdown, :yards, :nullified, :team, :player
|
158
196
|
def initialize(data)
|
159
|
-
@
|
197
|
+
@response = data
|
198
|
+
@attempt = data['attempt'] || data['att']
|
160
199
|
@att_yards = data['att_yards']
|
161
|
-
@complete = data['complete']
|
162
|
-
@firstdown = data['firstdown']
|
200
|
+
@complete = data['complete'] || data['cmp']
|
201
|
+
@firstdown = data['firstdown'] || data['fd']
|
163
202
|
@goaltogo = data['goaltogo']
|
164
|
-
@inside_20 = data['inside_20']
|
165
|
-
@interception = data['interception']
|
166
|
-
@sack = data['sack']
|
167
|
-
@sack_yards = data['sack_yards']
|
168
|
-
@touchdown = data['touchdown']
|
169
|
-
@yards = data['yards']
|
203
|
+
@inside_20 = data['inside_20'] || data['rz_att']
|
204
|
+
@interception = data['interception'] || data['int']
|
205
|
+
@sack = data['sack'] || data['sk']
|
206
|
+
@sack_yards = data['sack_yards'] || data['sk_yds']
|
207
|
+
@touchdown = data['touchdown'] || data['td']
|
208
|
+
@yards = data['yards'] || data['yds']
|
170
209
|
@team = OpenStruct.new(data['team']) if data['team']
|
171
210
|
@player = OpenStruct.new(data['player']) if data['player']
|
172
211
|
@nullified = data['nullified']
|
@@ -178,10 +217,12 @@ module Sportradar
|
|
178
217
|
end
|
179
218
|
|
180
219
|
class PlayPenaltyStatistics < Data
|
181
|
-
attr_accessor :penalty, :yards, :nullified, :team, :player
|
220
|
+
attr_accessor :penalty, :yards, :nullified, :team, :player, :first_down
|
182
221
|
def initialize(data)
|
183
|
-
@
|
184
|
-
@
|
222
|
+
@response = data
|
223
|
+
@penalty = data['penalty'] || data['abbr'] # unsure about abbr here
|
224
|
+
@yards = data['yards'] || data['yds']
|
225
|
+
@first_down = data['fd']
|
185
226
|
@team = OpenStruct.new(data['team']) if data['team']
|
186
227
|
@player = OpenStruct.new(data['player']) if data['player']
|
187
228
|
@nullified = data['nullified']
|
@@ -195,13 +236,15 @@ module Sportradar
|
|
195
236
|
class PlayPuntStatistics < Data
|
196
237
|
attr_accessor :attempt, :downed, :faircatch, :inside_20, :out_of_bounds, :touchback, :yards, :nullified, :team, :player
|
197
238
|
def initialize(data)
|
239
|
+
@response = data
|
198
240
|
data = data.first if data.is_a?(Array)
|
199
|
-
@attempt = data['attempt']
|
241
|
+
@attempt = data['attempt'] || data['punts']
|
200
242
|
@downed = data['downed']
|
201
|
-
@inside_20 = data['inside_20']
|
243
|
+
@inside_20 = data['inside_20'] || data['in20']
|
202
244
|
@out_of_bounds = data['out_of_bounds']
|
203
|
-
@touchback = data['touchback']
|
204
|
-
@yards = data['yards']
|
245
|
+
@touchback = data['touchback'] || data['tb']
|
246
|
+
@yards = data['yards'] || data['yds']
|
247
|
+
@blocked = data['blk']
|
205
248
|
@team = OpenStruct.new(data['team']) if data['team']
|
206
249
|
@player = OpenStruct.new(data['player']) if data['player']
|
207
250
|
@nullified = data['nullified']
|
@@ -215,14 +258,15 @@ module Sportradar
|
|
215
258
|
class PlayReceiveStatistics < Data
|
216
259
|
attr_accessor :firstdown, :goaltogo, :inside_20, :reception, :target, :touchdown, :yards, :yards_after_catch, :nullified, :team, :player
|
217
260
|
def initialize(data)
|
218
|
-
@
|
261
|
+
@response = data
|
262
|
+
@firstdown = data['firstdown'] || data['fd']
|
219
263
|
@goaltogo = data['goaltogo']
|
220
|
-
@inside_20 = data['inside_20']
|
221
|
-
@reception = data['reception']
|
222
|
-
@target = data['target']
|
223
|
-
@touchdown = data['touchdown']
|
224
|
-
@yards = data['yards']
|
225
|
-
@yards_after_catch = data['yards_after_catch']
|
264
|
+
@inside_20 = data['inside_20'] || data['rz_tar']
|
265
|
+
@reception = data['reception'] || data['rec']
|
266
|
+
@target = data['target'] || data['tar']
|
267
|
+
@touchdown = data['touchdown'] || data['td']
|
268
|
+
@yards = data['yards'] || data['yds']
|
269
|
+
@yards_after_catch = data['yards_after_catch'] || data['yac']
|
226
270
|
@team = OpenStruct.new(data['team']) if data['team']
|
227
271
|
@player = OpenStruct.new(data['player']) if data['player']
|
228
272
|
@nullified = data['nullified']
|
@@ -236,6 +280,7 @@ module Sportradar
|
|
236
280
|
class PlayFumbleStatistics < Data
|
237
281
|
attr_reader :own_rec, :own_rec_yards, :forced, :team, :player
|
238
282
|
def initialize(data)
|
283
|
+
@response = data
|
239
284
|
@own_rec = data['own_rec']
|
240
285
|
@own_rec_yards = data['own_rec_yards']
|
241
286
|
@forced = data['forced']
|
@@ -248,14 +293,15 @@ module Sportradar
|
|
248
293
|
class PlayRushStatistics < Data
|
249
294
|
attr_accessor :attempt, :firstdown, :tlost, :tlost_yards, :yards, :inside_20, :goal_to_go, :team, :player, :nullified, :touchdown
|
250
295
|
def initialize(data)
|
251
|
-
@
|
252
|
-
@
|
296
|
+
@response = data
|
297
|
+
@attempt = data['attempt'] || data['att']
|
298
|
+
@firstdown = data['firstdown'] || data['fd']
|
253
299
|
@goal_to_go = data['goal_to_go']
|
254
|
-
@inside_20 = data['inside_20']
|
300
|
+
@inside_20 = data['inside_20'] || data['rz_att']
|
255
301
|
@tlost = data['tlost']
|
256
302
|
@tlost_yards = data['tlost_yards']
|
257
|
-
@touchdown = data['touchdown']
|
258
|
-
@yards = data['yards']
|
303
|
+
@touchdown = data['touchdown'] || data['td']
|
304
|
+
@yards = data['yards'] || data['yds']
|
259
305
|
|
260
306
|
@team = OpenStruct.new(data['team']) if data['team']
|
261
307
|
@player = OpenStruct.new(data['player']) if data['player']
|
@@ -271,12 +317,14 @@ module Sportradar
|
|
271
317
|
class PlayKickStatistics < Data
|
272
318
|
attr_accessor :attempt, :yards, :gross_yards, :touchback, :team, :player, :endzone, :inside_20, :nullified
|
273
319
|
def initialize(data)
|
320
|
+
@response = data
|
274
321
|
@endzone = data['endzone']
|
275
|
-
@inside_20 = data['inside_20']
|
276
|
-
@attempt = data['attempt']
|
277
|
-
@
|
278
|
-
@
|
279
|
-
@
|
322
|
+
@inside_20 = data['inside_20'] || data['in20']
|
323
|
+
@attempt = data['attempt'] || data['kicks']
|
324
|
+
@returned = data['ret']
|
325
|
+
@yards = data['yards'] || data['yds']
|
326
|
+
@gross_yards = data['gross_yards'] || data['net_yds']
|
327
|
+
@touchback = data['touchback'] || data['tb']
|
280
328
|
@team = OpenStruct.new(data['team']) if data['team']
|
281
329
|
@player = OpenStruct.new(data['player']) if data['player']
|
282
330
|
@nullified = data['nullified']
|
@@ -290,6 +338,7 @@ module Sportradar
|
|
290
338
|
class ConversionStatistics < Data
|
291
339
|
attr_reader :stat_type, :attempt, :complete, :category, :player, :team
|
292
340
|
def initialize(data)
|
341
|
+
@response = data
|
293
342
|
@stat_type = data['stat_type']
|
294
343
|
@attempt = data['attempt']
|
295
344
|
@complete = data['complete']
|
@@ -302,14 +351,15 @@ module Sportradar
|
|
302
351
|
class PlayReturnStatistics < Data
|
303
352
|
attr_accessor :category, :downed, :faircatch, :out_of_bounds, :return, :touchback, :yards, :team, :nullified, :player, :touchdown
|
304
353
|
def initialize(data)
|
354
|
+
@response = data
|
305
355
|
@category = data['category']
|
306
356
|
@downed = data['downed']
|
307
|
-
@faircatch = data['faircatch']
|
357
|
+
@faircatch = data['faircatch'] || data['fc']
|
308
358
|
@out_of_bounds = data['out_of_bounds']
|
309
|
-
@return = data['return']
|
310
|
-
@touchback = data['touchback']
|
311
|
-
@touchdown = data['touchdown']
|
312
|
-
@yards = data['yards']
|
359
|
+
@return = data['return'] || data['returns']
|
360
|
+
@touchback = data['touchback'] || data['tb']
|
361
|
+
@touchdown = data['touchdown'] || data['td']
|
362
|
+
@yards = data['yards'] || data['yds']
|
313
363
|
@team = OpenStruct.new(data['team']) if data['team']
|
314
364
|
@player = OpenStruct.new(data['player']) if data['player']
|
315
365
|
@nullified = data['nullified']
|