Module: NBA::BoxScoreScoring

Defined in:
lib/nba/box_score_scoring.rb

Overview

Provides methods to retrieve scoring box score statistics

API:

  • public

Constant Summary collapse

PLAYER_STATS =

Result set name for player stats

Returns:

  • the result set name

API:

  • public

"PlayerStats".freeze
TEAM_STATS =

Result set name for team stats

Returns:

  • the result set name

API:

  • public

"TeamStats".freeze

Class Method Summary collapse

Class Method Details

.player_stats(game:, client: CLIENT) ⇒ Collection

Retrieves player scoring box score stats for a game

Examples:

stats = NBA::BoxScoreScoring.player_stats(game: "0022400001")
stats.each { |s| puts "#{s.player_name}: #{s.pct_pts_3pt}% from 3PT" }

Parameters:

  • the game ID or Game object

  • (defaults to: CLIENT)

    the API client to use

Returns:

  • a collection of player scoring box score stats

API:

  • public



27
28
29
30
# File 'lib/nba/box_score_scoring.rb', line 27

def self.player_stats(game:, client: CLIENT)
  path = "boxscorescoringv2?GameID=#{Utils.extract_id(game)}"
  ResponseParser.parse(client.get(path), result_set: PLAYER_STATS) { |data| build_player_stat(data) }
end

.team_stats(game:, client: CLIENT) ⇒ Collection

Retrieves team scoring box score stats for a game

Examples:

stats = NBA::BoxScoreScoring.team_stats(game: "0022400001")
stats.each { |s| puts "#{s.team_name}: #{s.pct_pts_paint}% in paint" }

Parameters:

  • the game ID or Game object

  • (defaults to: CLIENT)

    the API client to use

Returns:

  • a collection of team scoring box score stats

API:

  • public



41
42
43
44
# File 'lib/nba/box_score_scoring.rb', line 41

def self.team_stats(game:, client: CLIENT)
  path = "boxscorescoringv2?GameID=#{Utils.extract_id(game)}"
  ResponseParser.parse(client.get(path), result_set: TEAM_STATS) { |data| build_team_stat(data) }
end