Module: NBA::BoxScoreV3Helpers Private
- Defined in:
- lib/nba/box_score_v3_helpers.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Shared helper methods for V3 box score modules
Class Method Summary collapse
-
.advanced_efficiency_stats(stats) ⇒ Hash
private
Extracts advanced efficiency statistics from V3 API format.
-
.advanced_rating_stats(stats) ⇒ Hash
private
Extracts advanced rating statistics from V3 API format.
-
.advanced_tempo_stats(stats) ⇒ Hash
private
Extracts advanced tempo statistics from V3 API format.
-
.build_player_name(player) ⇒ String
private
Builds player full name from first and family name.
-
.counting_stats(stats) ⇒ Hash
private
Extracts counting statistics from V3 API format.
-
.extract_players(data, box_score_key) ⇒ Array?
private
Extracts all players from box score data.
-
.extract_teams(data, box_score_key) ⇒ Array?
private
Extracts both teams from box score data.
-
.field_goal_stats(stats) ⇒ Hash
private
Extracts field goal statistics from V3 API format.
-
.free_throw_stats(stats) ⇒ Hash
private
Extracts free throw statistics from V3 API format.
-
.other_counting_stats(stats) ⇒ Hash
private
Extracts other counting statistics from V3 API format.
-
.player_identity(player, game_id) ⇒ Hash
private
Extracts player identity attributes from V3 API format.
-
.rebound_stats(stats) ⇒ Hash
private
Extracts rebound and assist statistics from V3 API format.
-
.shooting_stats(stats) ⇒ Hash
private
Extracts shooting statistics from V3 API format.
-
.team_identity(team, game_id) ⇒ Hash
private
Extracts team identity attributes from V3 API format.
Class Method Details
.advanced_efficiency_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts advanced efficiency statistics from V3 API format
128 129 130 131 132 133 134 |
# File 'lib/nba/box_score_v3_helpers.rb', line 128 def self.advanced_efficiency_stats(stats) {ast_pct: stats["assistPercentage"], ast_tov: stats["assistToTurnover"], ast_ratio: stats["assistRatio"], oreb_pct: stats["reboundsOffensivePercentage"], dreb_pct: stats["reboundsDefensivePercentage"], reb_pct: stats["reboundsPercentage"], tov_pct: stats["turnoverPercentage"], efg_pct: stats["effectiveFieldGoalPercentage"], ts_pct: stats["trueShootingPercentage"], pie: stats["playerImpactEstimate"]} end |
.advanced_rating_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts advanced rating statistics from V3 API format
119 120 121 122 123 |
# File 'lib/nba/box_score_v3_helpers.rb', line 119 def self.(stats) {e_off_rating: stats["estimatedOffensiveRating"], off_rating: stats["offensiveRating"], e_def_rating: stats["estimatedDefensiveRating"], def_rating: stats["defensiveRating"], e_net_rating: stats["estimatedNetRating"], net_rating: stats["netRating"]} end |
.advanced_tempo_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts advanced tempo statistics from V3 API format
139 140 141 142 |
# File 'lib/nba/box_score_v3_helpers.rb', line 139 def self.advanced_tempo_stats(stats) {e_pace: stats["estimatedPace"], pace: stats["pace"], pace_per40: stats["pacePer40"], poss: stats["possessions"]} end |
.build_player_name(player) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builds player full name from first and family name
32 33 34 35 36 |
# File 'lib/nba/box_score_v3_helpers.rb', line 32 def self.build_player_name(player) first = player["firstName"] last = player["familyName"] "#{first} #{last}".strip end |
.counting_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts counting statistics from V3 API format
93 94 95 |
# File 'lib/nba/box_score_v3_helpers.rb', line 93 def self.counting_stats(stats) rebound_stats(stats).merge(other_counting_stats(stats)) end |
.extract_players(data, box_score_key) ⇒ Array?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts all players from box score data
43 44 45 46 47 48 49 50 |
# File 'lib/nba/box_score_v3_helpers.rb', line 43 def self.extract_players(data, box_score_key) box_score = data[box_score_key] return unless box_score home = box_score.dig("homeTeam", "players") || [] away = box_score.dig("awayTeam", "players") || [] home + away end |
.extract_teams(data, box_score_key) ⇒ Array?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts both teams from box score data
57 58 59 60 61 62 |
# File 'lib/nba/box_score_v3_helpers.rb', line 57 def self.extract_teams(data, box_score_key) box_score = data[box_score_key] return unless box_score [box_score["homeTeam"], box_score["awayTeam"]].compact end |
.field_goal_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts field goal statistics from V3 API format
75 76 77 78 79 |
# File 'lib/nba/box_score_v3_helpers.rb', line 75 def self.field_goal_stats(stats) {fgm: stats["fieldGoalsMade"], fga: stats["fieldGoalsAttempted"], fg_pct: stats["fieldGoalsPercentage"], fg3m: stats["threePointersMade"], fg3a: stats["threePointersAttempted"], fg3_pct: stats["threePointersPercentage"]} end |
.free_throw_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts free throw statistics from V3 API format
85 86 87 88 |
# File 'lib/nba/box_score_v3_helpers.rb', line 85 def self.free_throw_stats(stats) {ftm: stats["freeThrowsMade"], fta: stats["freeThrowsAttempted"], ft_pct: stats["freeThrowsPercentage"]} end |
.other_counting_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts other counting statistics from V3 API format
110 111 112 113 114 |
# File 'lib/nba/box_score_v3_helpers.rb', line 110 def self.other_counting_stats(stats) {stl: stats["steals"], blk: stats["blocks"], tov: stats["turnovers"], pf: stats["foulsPersonal"], pts: stats["points"], plus_minus: stats["plusMinusPoints"]} end |
.player_identity(player, game_id) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts player identity attributes from V3 API format
8 9 10 11 12 13 14 15 16 |
# File 'lib/nba/box_score_v3_helpers.rb', line 8 def self.player_identity(player, game_id) {game_id: game_id, team_id: player["teamId"], team_abbreviation: player["teamTricode"], team_city: player["teamCity"], player_id: player["personId"], player_name: build_player_name(player), start_position: player["position"], comment: player["comment"]} end |
.rebound_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts rebound and assist statistics from V3 API format
101 102 103 104 |
# File 'lib/nba/box_score_v3_helpers.rb', line 101 def self.rebound_stats(stats) {oreb: stats["reboundsOffensive"], dreb: stats["reboundsDefensive"], reb: stats["reboundsTotal"], ast: stats["assists"]} end |
.shooting_stats(stats) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts shooting statistics from V3 API format
67 68 69 |
# File 'lib/nba/box_score_v3_helpers.rb', line 67 def self.shooting_stats(stats) field_goal_stats(stats).merge(free_throw_stats(stats)) end |
.team_identity(team, game_id) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts team identity attributes from V3 API format
21 22 23 24 25 26 |
# File 'lib/nba/box_score_v3_helpers.rb', line 21 def self.team_identity(team, game_id) {game_id: game_id, team_id: team["teamId"], team_name: team["teamName"], team_abbreviation: team["teamTricode"], team_city: team["teamCity"]} end |