nba_rb 0.1.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +107 -0
- data/fixtures/vcr_cassettes/has_working_BoxscoreAdvanced_endpoint.yml +85 -0
- data/fixtures/vcr_cassettes/has_working_BoxscoreFourFactors_endpoint.yml +85 -0
- data/fixtures/vcr_cassettes/has_working_BoxscoreScoring_endpoint.yml +85 -0
- data/fixtures/vcr_cassettes/has_working_BoxscoreUsage_endpoint.yml +85 -0
- data/fixtures/vcr_cassettes/has_working_Boxscore_endpoint.yml +85 -0
- data/fixtures/vcr_cassettes/has_working_PlayerCareer_endpoint.yml +59 -0
- data/fixtures/vcr_cassettes/has_working_PlayerList_endpoint.yml +184 -0
- data/fixtures/vcr_cassettes/has_working_PlayerSummary_endpoint.yml +61 -0
- data/lib/helpers/stats_request.rb +8 -4
- data/lib/nba_rb.rb +1 -1
- data/lib/nba_rb/constants.rb +279 -277
- data/lib/nba_rb/game.rb +16 -195
- data/lib/nba_rb/game/boxscore.rb +94 -0
- data/lib/nba_rb/game/boxscore_advanced.rb +15 -0
- data/lib/nba_rb/game/boxscore_four_factors.rb +19 -0
- data/lib/nba_rb/game/boxscore_misc.rb +19 -0
- data/lib/nba_rb/game/boxscore_scoring.rb +25 -0
- data/lib/nba_rb/game/boxscore_usage.rb +19 -0
- data/lib/nba_rb/game/hustle.rb +29 -0
- data/lib/nba_rb/game/play_by_play.rb +30 -0
- data/lib/nba_rb/game/today_schedule.rb +63 -0
- data/lib/nba_rb/player.rb +75 -921
- data/lib/nba_rb/player/career.rb +111 -0
- data/lib/nba_rb/player/clutch_splits.rb +70 -0
- data/lib/nba_rb/player/dashboard.rb +104 -0
- data/lib/nba_rb/player/defense_tracking.rb +7 -0
- data/lib/nba_rb/player/game_logs.rb +34 -0
- data/lib/nba_rb/player/general_splits.rb +123 -0
- data/lib/nba_rb/player/in_game_splits.rb +55 -0
- data/lib/nba_rb/player/last_n_games_splits.rb +27 -0
- data/lib/nba_rb/player/list.rb +32 -0
- data/lib/nba_rb/player/opponent_splits.rb +39 -0
- data/lib/nba_rb/player/pass_tracking.rb +15 -0
- data/lib/nba_rb/player/performance_splits.rb +19 -0
- data/lib/nba_rb/player/player_dashboard.rb +104 -0
- data/lib/nba_rb/player/player_game_logs.rb +34 -0
- data/lib/nba_rb/player/player_general_splits.rb +123 -0
- data/lib/nba_rb/player/player_in_game_splits.rb +55 -0
- data/lib/nba_rb/player/player_last_n_games_splits.rb +27 -0
- data/lib/nba_rb/player/player_list.rb +32 -0
- data/lib/nba_rb/player/player_opponent_splits.rb +39 -0
- data/lib/nba_rb/player/player_performance_splits.rb +19 -0
- data/lib/nba_rb/player/player_profile.rb +19 -0
- data/lib/nba_rb/player/player_shooting_splits.rb +35 -0
- data/lib/nba_rb/player/player_summary.rb +29 -0
- data/lib/nba_rb/player/player_vs_player.rb +132 -0
- data/lib/nba_rb/player/player_year_over_year_splits.rb +17 -0
- data/lib/nba_rb/player/profile.rb +19 -0
- data/lib/nba_rb/player/rebound_log_tracking.rb +7 -0
- data/lib/nba_rb/player/rebound_tracking.rb +23 -0
- data/lib/nba_rb/player/shooting_splits.rb +35 -0
- data/lib/nba_rb/player/shot_log_tracking.rb +7 -0
- data/lib/nba_rb/player/shot_tracking.rb +31 -0
- data/lib/nba_rb/player/summary.rb +29 -0
- data/lib/nba_rb/player/year_over_year_splits.rb +17 -0
- data/lib/nba_rb/team.rb +31 -725
- data/lib/nba_rb/team/clutch_splits.rb +49 -0
- data/lib/nba_rb/team/common_roster.rb +28 -0
- data/lib/nba_rb/team/dashboard.rb +98 -0
- data/lib/nba_rb/team/game_logs.rb +27 -0
- data/lib/nba_rb/team/general_splits.rb +27 -0
- data/lib/nba_rb/team/in_game_splits.rb +23 -0
- data/lib/nba_rb/team/last_n_games_splits.rb +27 -0
- data/lib/nba_rb/team/lineups.rb +88 -0
- data/lib/nba_rb/team/list.rb +22 -0
- data/lib/nba_rb/team/opponent_splits.rb +19 -0
- data/lib/nba_rb/team/pass_tracking.rb +15 -0
- data/lib/nba_rb/team/performance_splits.rb +19 -0
- data/lib/nba_rb/team/player_on_off_detail.rb +15 -0
- data/lib/nba_rb/team/player_on_off_summary.rb +15 -0
- data/lib/nba_rb/team/players.rb +11 -0
- data/lib/nba_rb/team/rebound_tracking.rb +23 -0
- data/lib/nba_rb/team/seasons.rb +26 -0
- data/lib/nba_rb/team/shooting_splits.rb +35 -0
- data/lib/nba_rb/team/shot_tracking.rb +27 -0
- data/lib/nba_rb/team/stats.rb +17 -0
- data/lib/nba_rb/team/summary.rb +34 -0
- data/lib/nba_rb/team/vs_player.rb +121 -0
- data/lib/nba_rb/team/year_over_year_splits.rb +11 -0
- data/lib/nba_rb/version.rb +1 -1
- data/nba_rb.gemspec +2 -0
- metadata +105 -3
@@ -0,0 +1,63 @@
|
|
1
|
+
module NbaRb
|
2
|
+
module Game
|
3
|
+
class TodaySchedule < BaseClass
|
4
|
+
@endpoint = 'scoreboardV2'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_reader :endpoint
|
8
|
+
end
|
9
|
+
|
10
|
+
def endpoint
|
11
|
+
self.class.endpoint
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :league_id,
|
15
|
+
:game_date,
|
16
|
+
:day_offset,
|
17
|
+
:data
|
18
|
+
|
19
|
+
def initialize(*args)
|
20
|
+
super(*args)
|
21
|
+
|
22
|
+
@league_id ||= NbaRb::League.default
|
23
|
+
@game_date ||= Date.today.to_s.tr('-', ' ')
|
24
|
+
@day_offset ||= 0
|
25
|
+
|
26
|
+
res = stats_request(endpoint, 'LeagueID' => league_id,
|
27
|
+
'gameDate' => game_date,
|
28
|
+
'DayOffset' => day_offset)
|
29
|
+
|
30
|
+
@data = res['resultSets']
|
31
|
+
end
|
32
|
+
|
33
|
+
def arena_and_tv_info
|
34
|
+
create_stats_hash(@data[0])
|
35
|
+
end
|
36
|
+
|
37
|
+
def matchup_teams_info
|
38
|
+
# Each team has its own array of info. The second element in the array
|
39
|
+
# is the # of the game they play in. Example:
|
40
|
+
# [date_of_game, 1, '...', 'Charlotte']
|
41
|
+
# [date_of_game, 1, '...', 'Washington']
|
42
|
+
# The first game is Charlotte @ Washington
|
43
|
+
create_stats_hash(@data[1])
|
44
|
+
end
|
45
|
+
|
46
|
+
def series_standings
|
47
|
+
create_stats_hash(@data[2])
|
48
|
+
end
|
49
|
+
|
50
|
+
def last_meeting
|
51
|
+
create_stats_hash(@data[3])
|
52
|
+
end
|
53
|
+
|
54
|
+
def eastern_conference_standings_today
|
55
|
+
create_stats_hash(@data[4])
|
56
|
+
end
|
57
|
+
|
58
|
+
def western_conference_standings_today
|
59
|
+
create_stats_hash(@data[5])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/nba_rb/player.rb
CHANGED
@@ -1,924 +1,78 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
module NbaRb
|
2
|
+
module Player
|
3
|
+
class BaseClass
|
4
|
+
include Initializable
|
5
|
+
include StatsRequest
|
6
|
+
include StatsHash
|
7
|
+
|
8
|
+
require_relative './player/dashboard'
|
9
|
+
require_relative './player/career'
|
10
|
+
require_relative './player/clutch_splits'
|
11
|
+
require_relative './player/defense_tracking'
|
12
|
+
require_relative './player/game_logs'
|
13
|
+
require_relative './player/general_splits'
|
14
|
+
require_relative './player/in_game_splits'
|
15
|
+
require_relative './player/last_n_games_splits'
|
16
|
+
require_relative './player/list'
|
17
|
+
require_relative './player/opponent_splits'
|
18
|
+
require_relative './player/pass_tracking'
|
19
|
+
require_relative './player/performance_splits'
|
20
|
+
require_relative './player/player_vs_player'
|
21
|
+
require_relative './player/profile'
|
22
|
+
require_relative './player/rebound_log_tracking'
|
23
|
+
require_relative './player/shooting_splits'
|
24
|
+
require_relative './player/rebound_tracking'
|
25
|
+
require_relative './player/shooting_splits'
|
26
|
+
require_relative './player/shot_log_tracking'
|
27
|
+
require_relative './player/shot_tracking'
|
28
|
+
require_relative './player/summary'
|
29
|
+
require_relative './player/year_over_year_splits'
|
30
|
+
|
31
|
+
attr_accessor :first_name,
|
32
|
+
:last_name,
|
33
|
+
:only_current,
|
34
|
+
:data
|
35
|
+
|
36
|
+
def initialize(*args)
|
37
|
+
super(*args)
|
38
|
+
last_formatted = last_name.downcase.capitalize
|
39
|
+
first_formatted = first_name.downcase.capitalize
|
40
|
+
|
41
|
+
name = "#{last_formatted}, #{first_formatted}"
|
42
|
+
list = PlayerList.new.info
|
43
|
+
|
44
|
+
list['rowSet'].each do |player|
|
45
|
+
@data = player if player[1] == name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def id
|
50
|
+
@data[0]
|
51
|
+
end
|
52
|
+
|
53
|
+
def player_code
|
54
|
+
@data[5]
|
55
|
+
end
|
56
|
+
|
57
|
+
def rostered?
|
58
|
+
@data[2].zero?
|
59
|
+
end
|
60
|
+
|
61
|
+
def team_id
|
62
|
+
@data[6]
|
63
|
+
end
|
64
|
+
|
65
|
+
def team_name
|
66
|
+
@data[7] + ' ' + @data[8]
|
67
|
+
end
|
68
|
+
|
69
|
+
def team_abbreviation
|
70
|
+
@data[9]
|
71
|
+
end
|
72
|
+
|
73
|
+
def team_code
|
74
|
+
@data[10]
|
75
|
+
end
|
21
76
|
end
|
22
77
|
end
|
23
|
-
|
24
|
-
def id
|
25
|
-
@data[0]
|
26
|
-
end
|
27
|
-
|
28
|
-
def player_code
|
29
|
-
@data[5]
|
30
|
-
end
|
31
|
-
|
32
|
-
def rostered?
|
33
|
-
@data[2].zero?
|
34
|
-
end
|
35
|
-
|
36
|
-
def team_id
|
37
|
-
@data[6]
|
38
|
-
end
|
39
|
-
|
40
|
-
def team_name
|
41
|
-
@data[7] + ' ' + @data[8]
|
42
|
-
end
|
43
|
-
|
44
|
-
def team_abbreviation
|
45
|
-
@data[9]
|
46
|
-
end
|
47
|
-
|
48
|
-
def team_code
|
49
|
-
@data[10]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class PlayerList
|
54
|
-
include Initializable
|
55
|
-
include StatsRequest
|
56
|
-
include StatsHash
|
57
|
-
|
58
|
-
attr_accessor :league_id,
|
59
|
-
:season,
|
60
|
-
:only_current,
|
61
|
-
:data
|
62
|
-
|
63
|
-
def initialize(*args)
|
64
|
-
super(*args)
|
65
|
-
|
66
|
-
@league_id ||= League.NBA
|
67
|
-
@season ||= NbaRb::CURRENT_SEASON
|
68
|
-
@only_current ||= 1
|
69
|
-
|
70
|
-
res = stats_request('commonallplayers', 'LeagueID' => league_id,
|
71
|
-
'Season' => season,
|
72
|
-
'IsOnlyCurrentSeason' => only_current)
|
73
|
-
|
74
|
-
@data = res['resultSets']
|
75
|
-
end
|
76
|
-
|
77
|
-
def info
|
78
|
-
@data[0]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class PlayerSummary
|
83
|
-
include Initializable
|
84
|
-
include StatsRequest
|
85
|
-
include StatsHash
|
86
|
-
|
87
|
-
attr_accessor :player_id,
|
88
|
-
:data
|
89
|
-
|
90
|
-
def initialize(*args)
|
91
|
-
super(*args)
|
92
|
-
@player_id ||= player_id
|
93
|
-
|
94
|
-
res = stats_request('commonplayerinfo', 'PlayerID' => player_id)
|
95
|
-
|
96
|
-
@data = res['resultSets']
|
97
|
-
end
|
98
|
-
|
99
|
-
def info
|
100
|
-
create_stats_hash(@data[0])
|
101
|
-
end
|
102
|
-
|
103
|
-
def headline_stats
|
104
|
-
create_stats_hash(@data[1])
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
class PlayerDashboard
|
109
|
-
include Initializable
|
110
|
-
include StatsRequest
|
111
|
-
include StatsHash
|
112
|
-
|
113
|
-
class << self
|
114
|
-
attr_reader :endpoint
|
115
|
-
end
|
116
|
-
|
117
|
-
def endpoint
|
118
|
-
self.class.endpoint
|
119
|
-
end
|
120
|
-
|
121
|
-
attr_accessor :player_id,
|
122
|
-
:team_id,
|
123
|
-
:measure_type,
|
124
|
-
:per_mode,
|
125
|
-
:plus_minus,
|
126
|
-
:pace_adjust,
|
127
|
-
:rank,
|
128
|
-
:league_id,
|
129
|
-
:season,
|
130
|
-
:season_type,
|
131
|
-
:po_round,
|
132
|
-
:outcome,
|
133
|
-
:location,
|
134
|
-
:month,
|
135
|
-
:season_segment,
|
136
|
-
:date_from,
|
137
|
-
:date_to,
|
138
|
-
:opponent_team_id,
|
139
|
-
:vs_conference,
|
140
|
-
:vs_division,
|
141
|
-
:game_segment,
|
142
|
-
:period,
|
143
|
-
:shot_clock_range,
|
144
|
-
:last_n_games,
|
145
|
-
:data
|
146
|
-
|
147
|
-
@endpoint = ''
|
148
|
-
|
149
|
-
def initialize(*args)
|
150
|
-
super(*args)
|
151
|
-
|
152
|
-
@team_id ||= 0
|
153
|
-
@measure_type ||= MeasureType.default
|
154
|
-
@per_mode ||= PerMode.default
|
155
|
-
@plus_minus ||= PlusMinus.default
|
156
|
-
@pace_adjust ||= PaceAdjust.default
|
157
|
-
@rank ||= PaceAdjust.default
|
158
|
-
@league_id ||= League.default
|
159
|
-
@season ||= NbaRb::CURRENT_SEASON
|
160
|
-
@season_type ||= SeasonType.default
|
161
|
-
@po_round ||= PlayoffRound.default
|
162
|
-
@outcome ||= Outcome.default
|
163
|
-
@location ||= Location.default
|
164
|
-
@month ||= Month.default
|
165
|
-
@season_segment ||= SeasonSegment.default
|
166
|
-
@date_from ||= DateFrom.default
|
167
|
-
@date_to ||= DateTo.default
|
168
|
-
@opponent_team_id ||= OpponentTeamID.default
|
169
|
-
@vs_conference ||= VsConference.default
|
170
|
-
@vs_division ||= VsDivision.default
|
171
|
-
@game_segment ||= GameSegment.default
|
172
|
-
@period ||= Period.default
|
173
|
-
@shot_clock_range ||= ShotClockRange.default
|
174
|
-
@last_n_games ||= LastNGames.default
|
175
|
-
|
176
|
-
res = stats_request(endpoint, 'PlayerID' => player_id,
|
177
|
-
'TeamID' => team_id,
|
178
|
-
'MeasureType' => measure_type,
|
179
|
-
'PerMode' => per_mode,
|
180
|
-
'PlusMinus' => plus_minus,
|
181
|
-
'PaceAdjust' => pace_adjust,
|
182
|
-
'Rank' => rank,
|
183
|
-
'LeagueID' => league_id,
|
184
|
-
'Season' => season,
|
185
|
-
'SeasonType' => season_type,
|
186
|
-
'PORound' => po_round,
|
187
|
-
'Outcome' => outcome,
|
188
|
-
'Location' => location,
|
189
|
-
'Month' => month,
|
190
|
-
'SeasonSegment' => season_segment,
|
191
|
-
'DateFrom' => date_from,
|
192
|
-
'DateTo' => date_to,
|
193
|
-
'OpponentTeamID' => opponent_team_id,
|
194
|
-
'VsConference' => vs_conference,
|
195
|
-
'VsDivision' => vs_division,
|
196
|
-
'GameSegment' => game_segment,
|
197
|
-
'Period' => period,
|
198
|
-
'ShotClockRange' => shot_clock_range,
|
199
|
-
'LastNGames' => last_n_games)
|
200
|
-
|
201
|
-
@data = res['resultSets']
|
202
|
-
end
|
203
|
-
|
204
|
-
def overall
|
205
|
-
create_stats_hash(@data[0])
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
class PlayerGeneralSplits < PlayerDashboard
|
210
|
-
@endpoint = 'playerdashboardbygeneralsplits'
|
211
|
-
|
212
|
-
def location
|
213
|
-
create_stats_hash(@data[1])
|
214
|
-
end
|
215
|
-
|
216
|
-
def home
|
217
|
-
location[0]
|
218
|
-
end
|
219
|
-
|
220
|
-
def away
|
221
|
-
location[1]
|
222
|
-
end
|
223
|
-
|
224
|
-
def win_losses
|
225
|
-
create_stats_hash(@data[2])
|
226
|
-
end
|
227
|
-
|
228
|
-
def in_wins
|
229
|
-
win_losses[0]
|
230
|
-
end
|
231
|
-
|
232
|
-
def in_losses
|
233
|
-
win_losses[1]
|
234
|
-
end
|
235
|
-
|
236
|
-
def by_month
|
237
|
-
create_stats_hash(@data[3])
|
238
|
-
end
|
239
|
-
|
240
|
-
def in_october
|
241
|
-
by_month[0]
|
242
|
-
end
|
243
|
-
|
244
|
-
def in_november
|
245
|
-
by_month[1]
|
246
|
-
end
|
247
|
-
|
248
|
-
def in_december
|
249
|
-
by_month[2]
|
250
|
-
end
|
251
|
-
|
252
|
-
def in_january
|
253
|
-
by_month[3]
|
254
|
-
end
|
255
|
-
|
256
|
-
def in_february
|
257
|
-
by_month[4]
|
258
|
-
end
|
259
|
-
|
260
|
-
def in_march
|
261
|
-
by_month[5]
|
262
|
-
end
|
263
|
-
|
264
|
-
def in_april
|
265
|
-
by_month[6]
|
266
|
-
end
|
267
|
-
|
268
|
-
def in_may
|
269
|
-
by_month[7]
|
270
|
-
end
|
271
|
-
|
272
|
-
def in_june
|
273
|
-
by_month[8]
|
274
|
-
end
|
275
|
-
|
276
|
-
def pre_post_all_star
|
277
|
-
create_stats_hash(@data[4])
|
278
|
-
end
|
279
|
-
|
280
|
-
def pre_all_star
|
281
|
-
pre_post_all_star[0]
|
282
|
-
end
|
283
|
-
|
284
|
-
def post_all_star
|
285
|
-
pre_post_all_star[1]
|
286
|
-
end
|
287
|
-
|
288
|
-
def starting_position
|
289
|
-
create_stats_hash(@data[5])
|
290
|
-
end
|
291
|
-
|
292
|
-
def as_starter
|
293
|
-
starting_position[0]
|
294
|
-
end
|
295
|
-
|
296
|
-
def as_bench
|
297
|
-
starting_position[1]
|
298
|
-
end
|
299
|
-
|
300
|
-
def days_rest
|
301
|
-
create_stats_hash(@data[6])
|
302
|
-
end
|
303
|
-
|
304
|
-
def zero_rest_days
|
305
|
-
days_rest[0]
|
306
|
-
end
|
307
|
-
|
308
|
-
def one_rest_day
|
309
|
-
days_rest[1]
|
310
|
-
end
|
311
|
-
|
312
|
-
def two_rest_days
|
313
|
-
days_rest[2]
|
314
|
-
end
|
315
|
-
|
316
|
-
def three_rest_days
|
317
|
-
days_rest[3]
|
318
|
-
end
|
319
|
-
|
320
|
-
def four_rest_days
|
321
|
-
days_rest[4]
|
322
|
-
end
|
323
|
-
|
324
|
-
def six_plus_rest_days
|
325
|
-
days_rest[5]
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
class PlayerOpponentSplits < PlayerDashboard
|
330
|
-
@endpoint = 'playerdashboardbyopponent'
|
331
|
-
|
332
|
-
def by_conference
|
333
|
-
create_stats_hash(@data[1])
|
334
|
-
end
|
335
|
-
|
336
|
-
def vs_east
|
337
|
-
by_conference[0]
|
338
|
-
end
|
339
|
-
|
340
|
-
def vs_west
|
341
|
-
by_conference[1]
|
342
|
-
end
|
343
|
-
|
344
|
-
def by_division
|
345
|
-
create_stats_hash(@data[2])
|
346
|
-
end
|
347
|
-
|
348
|
-
def vs_division(division)
|
349
|
-
by_division.each do |hash|
|
350
|
-
return hash if hash['GROUP_VALUE'].downcase.include? division.downcase
|
351
|
-
end
|
352
|
-
end
|
353
|
-
|
354
|
-
def by_opponent
|
355
|
-
create_stats_hash(@data[3])
|
356
|
-
end
|
357
|
-
|
358
|
-
def vs_team(team)
|
359
|
-
by_opponent.each do |hash|
|
360
|
-
return hash if hash['GROUP_VALUE'].downcase.include? team.downcase
|
361
|
-
end
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
class PlayerLastNGamesSplits < PlayerDashboard
|
366
|
-
@endpoint = 'playerdashboardbylastngames'
|
367
|
-
|
368
|
-
def last5
|
369
|
-
create_stats_hash(@data[1])
|
370
|
-
end
|
371
|
-
|
372
|
-
def last10
|
373
|
-
create_stats_hash(@data[2])
|
374
|
-
end
|
375
|
-
|
376
|
-
def last15
|
377
|
-
create_stats_hash(@data[3])
|
378
|
-
end
|
379
|
-
|
380
|
-
def last20
|
381
|
-
create_stats_hash(@data[4])
|
382
|
-
end
|
383
|
-
|
384
|
-
def gamenumber
|
385
|
-
create_stats_hash(@data[5])
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
class PlayerInGameSplits < PlayerDashboard
|
390
|
-
@endpoint = 'playerdashboardbygamesplits'
|
391
|
-
|
392
|
-
def by_half
|
393
|
-
create_stats_hash(@data[1])
|
394
|
-
end
|
395
|
-
|
396
|
-
def first_half
|
397
|
-
by_half[0]
|
398
|
-
end
|
399
|
-
|
400
|
-
def second_half
|
401
|
-
by_half[1]
|
402
|
-
end
|
403
|
-
|
404
|
-
def by_period
|
405
|
-
create_stats_hash(@data[2])
|
406
|
-
end
|
407
|
-
|
408
|
-
def first_quarter
|
409
|
-
by_period[0]
|
410
|
-
end
|
411
|
-
|
412
|
-
def second_quarter
|
413
|
-
by_period[1]
|
414
|
-
end
|
415
|
-
|
416
|
-
def third_quarter
|
417
|
-
by_period[2]
|
418
|
-
end
|
419
|
-
|
420
|
-
def fourth_quarter
|
421
|
-
by_period[3]
|
422
|
-
end
|
423
|
-
|
424
|
-
def by_score_margin
|
425
|
-
create_stats_hash(@data[3])
|
426
|
-
end
|
427
|
-
|
428
|
-
def tied_games
|
429
|
-
by_score_margin[0]
|
430
|
-
end
|
431
|
-
|
432
|
-
def close_games
|
433
|
-
by_score_margin[1]
|
434
|
-
end
|
435
|
-
|
436
|
-
def by_actual_margin
|
437
|
-
create_stats_hash(@data[4])
|
438
|
-
end
|
439
|
-
end
|
440
|
-
|
441
|
-
class PlayerClutchSplits < PlayerDashboard
|
442
|
-
@endpoint = 'playerdashboardbyclutch'
|
443
|
-
|
444
|
-
def last5min_deficit_5point
|
445
|
-
''"
|
446
|
-
Results in last 5 minutes <= 5 points
|
447
|
-
"''
|
448
|
-
create_stats_hash(@data[1])
|
449
|
-
end
|
450
|
-
|
451
|
-
def last3min_deficit_5point
|
452
|
-
''"
|
453
|
-
Results in last 5 minutes <= 5 points
|
454
|
-
"''
|
455
|
-
create_stats_hash(@data[2])
|
456
|
-
end
|
457
|
-
|
458
|
-
def last1min_deficit_5point
|
459
|
-
''"
|
460
|
-
Results in last 5 minutes <= 5 points
|
461
|
-
"''
|
462
|
-
create_stats_hash(@data[3])
|
463
|
-
end
|
464
|
-
|
465
|
-
def last30sec_deficit_3point
|
466
|
-
''"
|
467
|
-
Results in last 5 minutes <= 5 points
|
468
|
-
"''
|
469
|
-
create_stats_hash(@data[4])
|
470
|
-
end
|
471
|
-
|
472
|
-
def last10sec_deficit_3point
|
473
|
-
''"
|
474
|
-
Results in last 5 minutes <= 5 points
|
475
|
-
"''
|
476
|
-
create_stats_hash(@data[5])
|
477
|
-
end
|
478
|
-
|
479
|
-
def last5min_plusminus_5point
|
480
|
-
''"
|
481
|
-
Last 5 minutes +/= 5 points
|
482
|
-
"''
|
483
|
-
create_stats_hash(@data[6])
|
484
|
-
end
|
485
|
-
|
486
|
-
def last3min_plusminus_5point
|
487
|
-
''"
|
488
|
-
Last 3 minutes +/= 5 points
|
489
|
-
"''
|
490
|
-
create_stats_hash(@data[7])
|
491
|
-
end
|
492
|
-
|
493
|
-
def last1min_plusminus_5point
|
494
|
-
''"
|
495
|
-
Last 1 minutes +/= 5 points
|
496
|
-
"''
|
497
|
-
create_stats_hash(@data[8])
|
498
|
-
end
|
499
|
-
|
500
|
-
def last30sec_plusminus_5point
|
501
|
-
''"
|
502
|
-
Last 30 seconds +/= 3 points
|
503
|
-
"''
|
504
|
-
create_stats_hash(@data[9])
|
505
|
-
end
|
506
|
-
end
|
507
|
-
|
508
|
-
class PlayerShootingSplits < PlayerDashboard
|
509
|
-
@endpoint = 'playerdashboardbyshootingsplits'
|
510
|
-
|
511
|
-
def shot_5ft
|
512
|
-
create_stats_hash(@data[1])
|
513
|
-
end
|
514
|
-
|
515
|
-
def shot_8ft
|
516
|
-
create_stats_hash(@data[2])
|
517
|
-
end
|
518
|
-
|
519
|
-
def shot_areas
|
520
|
-
create_stats_hash(@data[3])
|
521
|
-
end
|
522
|
-
|
523
|
-
def assisted_shots
|
524
|
-
create_stats_hash(@data[4])
|
525
|
-
end
|
526
|
-
|
527
|
-
def shot_types_summary
|
528
|
-
create_stats_hash(@data[5])
|
529
|
-
end
|
530
|
-
|
531
|
-
def shot_types_detail
|
532
|
-
create_stats_hash(@data[6])
|
533
|
-
end
|
534
|
-
|
535
|
-
def assissted_by
|
536
|
-
create_stats_hash(@data[7])
|
537
|
-
end
|
538
|
-
end
|
539
|
-
|
540
|
-
class PlayerPerformanceSplits < PlayerDashboard
|
541
|
-
@endpoint = 'playerdashboardbyteamperformance'
|
542
|
-
|
543
|
-
def score_differential
|
544
|
-
create_stats_hash(@data[1])
|
545
|
-
end
|
546
|
-
|
547
|
-
def points_scored
|
548
|
-
create_stats_hash(@data[2])
|
549
|
-
end
|
550
|
-
|
551
|
-
def points_against
|
552
|
-
create_stats_hash(@data[3])
|
553
|
-
end
|
554
|
-
end
|
555
|
-
|
556
|
-
class PlayerYearOverYearSplits < PlayerDashboard
|
557
|
-
@endpoint = 'playerdashboardbyyearoveryear'
|
558
|
-
|
559
|
-
def splits_by_year
|
560
|
-
create_stats_hash(@data[1])
|
561
|
-
end
|
562
|
-
|
563
|
-
def by_year(year)
|
564
|
-
splits_by_year.each do |hash|
|
565
|
-
return hash if hash['GROUP_VALUE'].include? year
|
566
|
-
end
|
567
|
-
end
|
568
|
-
end
|
569
|
-
|
570
|
-
class PlayerCareer
|
571
|
-
include Initializable
|
572
|
-
include StatsRequest
|
573
|
-
include StatsHash
|
574
|
-
|
575
|
-
class << self
|
576
|
-
attr_reader :endpoint
|
577
|
-
end
|
578
|
-
|
579
|
-
def endpoint
|
580
|
-
self.class.endpoint
|
581
|
-
end
|
582
|
-
|
583
|
-
attr_accessor :player_id,
|
584
|
-
:league_id,
|
585
|
-
:per_mode,
|
586
|
-
:data
|
587
|
-
|
588
|
-
def initialize(*args)
|
589
|
-
super(*args)
|
590
|
-
|
591
|
-
@per_mode ||= PerMode.per_game
|
592
|
-
@league_id ||= League.NBA
|
593
|
-
|
594
|
-
res = stats_request('playercareerstats', 'PlayerID' => player_id,
|
595
|
-
'LeagueID' => league_id,
|
596
|
-
'PerMode' => per_mode)
|
597
|
-
|
598
|
-
@data = res['resultSets']
|
599
|
-
end
|
600
|
-
|
601
|
-
def regular_season_totals
|
602
|
-
create_stats_hash(@data[0])
|
603
|
-
end
|
604
|
-
|
605
|
-
def season_totals_by_year(year)
|
606
|
-
regular_season_totals.each do |hash|
|
607
|
-
return hash if hash['SEASON_ID'].include? year
|
608
|
-
end
|
609
|
-
end
|
610
|
-
|
611
|
-
def regular_season_career_totals
|
612
|
-
create_stats_hash(@data[1])
|
613
|
-
end
|
614
|
-
|
615
|
-
def post_season_totals
|
616
|
-
create_stats_hash(@data[2])
|
617
|
-
end
|
618
|
-
|
619
|
-
def post_season_totals_by_year(year)
|
620
|
-
post_season_totals.each do |hash|
|
621
|
-
return hash if hash['SEASON_ID'].include? year
|
622
|
-
end
|
623
|
-
end
|
624
|
-
|
625
|
-
def post_season_career_totals
|
626
|
-
create_stats_hash(@data[3])
|
627
|
-
end
|
628
|
-
|
629
|
-
def all_star_season_totals
|
630
|
-
create_stats_hash(@data[4])
|
631
|
-
end
|
632
|
-
|
633
|
-
def all_star_season_totals_by_year(year)
|
634
|
-
all_star_season_totals.each do |hash|
|
635
|
-
return hash if hash['SEASON_ID'].include? year
|
636
|
-
end
|
637
|
-
end
|
638
|
-
|
639
|
-
def career_all_star_season_totals
|
640
|
-
create_stats_hash(@data[5])
|
641
|
-
end
|
642
|
-
|
643
|
-
def college_season_totals
|
644
|
-
create_stats_hash(@data[6])
|
645
|
-
end
|
646
|
-
|
647
|
-
def college_season_totals_by_year(year)
|
648
|
-
college_season_totals.each do |hash|
|
649
|
-
return hash if hash['SEASON_ID'].include? year
|
650
|
-
end
|
651
|
-
end
|
652
|
-
|
653
|
-
def career_college_season_totals
|
654
|
-
create_stats_hash(@data[7])
|
655
|
-
end
|
656
|
-
|
657
|
-
def regular_season_rankings
|
658
|
-
create_stats_hash(@data[8])
|
659
|
-
end
|
660
|
-
|
661
|
-
def regular_season_rankings_by_year(year)
|
662
|
-
regular_season_rankings.each do |hash|
|
663
|
-
return hash if hash['SEASON_ID'].include? year
|
664
|
-
end
|
665
|
-
end
|
666
|
-
|
667
|
-
def post_season_rankings
|
668
|
-
create_stats_hash(@data[9])
|
669
|
-
end
|
670
|
-
|
671
|
-
def post_season_rankings_by_year(year)
|
672
|
-
post_season_rankings.each do |hash|
|
673
|
-
return hash if hash['SEASON_ID'].include? year
|
674
|
-
end
|
675
|
-
end
|
676
|
-
end
|
677
|
-
|
678
|
-
class PlayerProfile < PlayerCareer
|
679
|
-
@endpoint = 'playerprofilev2'
|
680
|
-
|
681
|
-
def season_highs
|
682
|
-
create_stats_hash(@data[10])
|
683
|
-
end
|
684
|
-
|
685
|
-
def career_highs
|
686
|
-
create_stats_hash(@data[11])
|
687
|
-
end
|
688
|
-
|
689
|
-
def next_game
|
690
|
-
create_stats_hash(@data[12])
|
691
|
-
end
|
692
|
-
end
|
693
|
-
|
694
|
-
class PlayerGameLogs
|
695
|
-
include Initializable
|
696
|
-
include StatsRequest
|
697
|
-
include StatsHash
|
698
|
-
|
699
|
-
attr_accessor :player_id,
|
700
|
-
:league_id,
|
701
|
-
:season,
|
702
|
-
:season_type,
|
703
|
-
:data
|
704
|
-
|
705
|
-
def initialize(*args)
|
706
|
-
super(*args)
|
707
|
-
|
708
|
-
@league_id ||= League.NBA
|
709
|
-
@season ||= NbaRb::CURRENT_SEASON
|
710
|
-
@season_type ||= SeasonType.regular
|
711
|
-
|
712
|
-
res = stats_request('playergamelog', 'PlayerID' => player_id,
|
713
|
-
'LeagueID' => league_id,
|
714
|
-
'Season' => season,
|
715
|
-
'SeasonType' => season_type)
|
716
|
-
|
717
|
-
@data = res['resultSets']
|
718
|
-
end
|
719
|
-
|
720
|
-
def info
|
721
|
-
create_stats_hash(@data[0])
|
722
|
-
end
|
723
|
-
end
|
724
|
-
|
725
|
-
class PlayerShotTracking < PlayerDashboard
|
726
|
-
@endpoint = 'playerdashptshots'
|
727
|
-
|
728
|
-
def general_shooting
|
729
|
-
create_stats_hash(@data[1])
|
730
|
-
end
|
731
|
-
|
732
|
-
def shot_clock_shooting
|
733
|
-
create_stats_hash(@data[2])
|
734
|
-
end
|
735
|
-
|
736
|
-
def dribble_shooting
|
737
|
-
create_stats_hash(@data[3])
|
738
|
-
end
|
739
|
-
|
740
|
-
def closest_defender_shooting
|
741
|
-
create_stats_hash(@data[4])
|
742
|
-
end
|
743
|
-
|
744
|
-
def closest_defender_shooting_long
|
745
|
-
create_stats_hash(@data[5])
|
746
|
-
end
|
747
|
-
|
748
|
-
def touch_time_shooting
|
749
|
-
create_stats_hash(@data[6])
|
750
|
-
end
|
751
|
-
end
|
752
|
-
|
753
|
-
class PlayerReboundTracking < PlayerDashboard
|
754
|
-
@endpoint = 'playerdashptreb'
|
755
|
-
|
756
|
-
def shot_type_rebounding
|
757
|
-
create_stats_hash(@data[1])
|
758
|
-
end
|
759
|
-
|
760
|
-
def num_contested_rebounding
|
761
|
-
create_stats_hash(@data[2])
|
762
|
-
end
|
763
|
-
|
764
|
-
def shot_distance_rebounding
|
765
|
-
create_stats_hash(@data[3])
|
766
|
-
end
|
767
|
-
|
768
|
-
def rebound_distance_rebounding
|
769
|
-
create_stats_hash(@data[4])
|
770
|
-
end
|
771
|
-
end
|
772
|
-
|
773
|
-
class PlayerPassTracking < PlayerDashboard
|
774
|
-
@endpoint = 'playerdashptpass'
|
775
|
-
|
776
|
-
def passes_made
|
777
|
-
create_stats_hash(@data[0])
|
778
|
-
end
|
779
|
-
|
780
|
-
def passes_recieved
|
781
|
-
create_stats_hash(@data[1])
|
782
|
-
end
|
783
|
-
end
|
784
|
-
|
785
|
-
class PlayerDefenseTracking < PlayerDashboard
|
786
|
-
@endpoint = 'playerdashptshotdefend'
|
787
|
-
end
|
788
|
-
|
789
|
-
class PlayerShotLogTracking < PlayerDashboard
|
790
|
-
@endpoint = 'playerdashptshotlog'
|
791
|
-
end
|
792
|
-
|
793
|
-
class PlayerReboundLogTracking < PlayerDashboard
|
794
|
-
@endpoint = 'playerdashptreboundlogs'
|
795
|
-
end
|
796
|
-
|
797
|
-
class PlayerVsPlayer
|
798
|
-
include Initializable
|
799
|
-
include StatsRequest
|
800
|
-
include StatsHash
|
801
|
-
|
802
|
-
attr_accessor :player_id,
|
803
|
-
:vs_player_id,
|
804
|
-
:team_id,
|
805
|
-
:measure_type,
|
806
|
-
:per_mode,
|
807
|
-
:plus_minus,
|
808
|
-
:pace_adjust,
|
809
|
-
:rank,
|
810
|
-
:league_id,
|
811
|
-
:season,
|
812
|
-
:season_type,
|
813
|
-
:po_round,
|
814
|
-
:outcome,
|
815
|
-
:location,
|
816
|
-
:month,
|
817
|
-
:season_segment,
|
818
|
-
:date_from,
|
819
|
-
:date_to,
|
820
|
-
:opponent_team_id,
|
821
|
-
:vs_conference,
|
822
|
-
:vs_division,
|
823
|
-
:game_segment,
|
824
|
-
:period,
|
825
|
-
:shot_clock_range,
|
826
|
-
:last_n_games,
|
827
|
-
:data
|
828
|
-
|
829
|
-
def initialize(*args)
|
830
|
-
super(*args)
|
831
|
-
|
832
|
-
@team_id ||= 0
|
833
|
-
@measure_type ||= MeasureType.default
|
834
|
-
@per_mode ||= PerMode.default
|
835
|
-
@plus_minus ||= PlusMinus.default
|
836
|
-
@pace_adjust ||= PaceAdjust.default
|
837
|
-
@rank ||= PaceAdjust.default
|
838
|
-
@league_id ||= League.default
|
839
|
-
@season ||= NbaRb::CURRENT_SEASON
|
840
|
-
@season_type ||= SeasonType.default
|
841
|
-
@po_round ||= PlayoffRound.default
|
842
|
-
@outcome ||= Outcome.default
|
843
|
-
@location ||= Location.default
|
844
|
-
@month ||= Month.default
|
845
|
-
@season_segment ||= SeasonSegment.default
|
846
|
-
@date_from ||= DateFrom.default
|
847
|
-
@date_to ||= DateTo.default
|
848
|
-
@opponent_team_id ||= OpponentTeamID.default
|
849
|
-
@vs_conference ||= VsConference.default
|
850
|
-
@vs_division ||= VsDivision.default
|
851
|
-
@game_segment ||= GameSegment.default
|
852
|
-
@period ||= Period.default
|
853
|
-
@shot_clock_range ||= ShotClockRange.default
|
854
|
-
@last_n_games ||= LastNGames.default
|
855
|
-
|
856
|
-
res = stats_request('playervsplayer', 'PlayerID' => player_id,
|
857
|
-
'VsPlayerID' => vs_player_id,
|
858
|
-
'TeamID' => team_id,
|
859
|
-
'MeasureType' => measure_type,
|
860
|
-
'PerMode' => per_mode,
|
861
|
-
'PlusMinus' => plus_minus,
|
862
|
-
'PaceAdjust' => pace_adjust,
|
863
|
-
'Rank' => rank,
|
864
|
-
'LeagueID' => league_id,
|
865
|
-
'Season' => season,
|
866
|
-
'SeasonType' => season_type,
|
867
|
-
'PORound' => po_round,
|
868
|
-
'Outcome' => outcome,
|
869
|
-
'Location' => location,
|
870
|
-
'Month' => month,
|
871
|
-
'SeasonSegment' => season_segment,
|
872
|
-
'DateFrom' => date_from,
|
873
|
-
'DateTo' => date_to,
|
874
|
-
'OpponentTeamID' => opponent_team_id,
|
875
|
-
'VsConference' => vs_conference,
|
876
|
-
'VsDivision' => vs_division,
|
877
|
-
'GameSegment' => game_segment,
|
878
|
-
'Period' => period,
|
879
|
-
'ShotClockRange' => shot_clock_range,
|
880
|
-
'LastNGames' => last_n_games)
|
881
|
-
|
882
|
-
@data = res['resultSets']
|
883
|
-
end
|
884
|
-
|
885
|
-
def overall
|
886
|
-
create_stats_hash(@data[0])
|
887
|
-
end
|
888
|
-
|
889
|
-
def on_off_court
|
890
|
-
create_stats_hash(@data[1])
|
891
|
-
end
|
892
|
-
|
893
|
-
def shot_distance_overall
|
894
|
-
create_stats_hash(@data[2])
|
895
|
-
end
|
896
|
-
|
897
|
-
def shot_distance_on_court
|
898
|
-
create_stats_hash(@data[3])
|
899
|
-
end
|
900
|
-
|
901
|
-
def shot_distance_off_court
|
902
|
-
create_stats_hash(@data[4])
|
903
|
-
end
|
904
|
-
|
905
|
-
def shot_area_overall
|
906
|
-
create_stats_hash(@data[5])
|
907
|
-
end
|
908
|
-
|
909
|
-
def shot_area_on_court
|
910
|
-
create_stats_hash(@data[6])
|
911
|
-
end
|
912
|
-
|
913
|
-
def shot_area_off_court
|
914
|
-
create_stats_hash(@data[7])
|
915
|
-
end
|
916
|
-
|
917
|
-
def player_info
|
918
|
-
create_stats_hash(@data[8])
|
919
|
-
end
|
920
|
-
|
921
|
-
def vs_player_info
|
922
|
-
create_stats_hash(@data[9])
|
923
|
-
end
|
924
78
|
end
|