Module: NBA::BoxScoreTraditional

Defined in:
lib/nba/box_score_traditional.rb

Overview

Provides methods to retrieve traditional 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 box score stats for a game

Examples:

stats = NBA::BoxScoreTraditional.player_stats(game: "0022400001")
stats.each { |s| puts "#{s.player_name}: #{s.pts} pts" }

Parameters:

  • the game ID or Game object

  • (defaults to: CLIENT)

    the API client to use

Returns:

  • a collection of player box score stats

API:

  • public



26
27
28
29
# File 'lib/nba/box_score_traditional.rb', line 26

def self.player_stats(game:, client: CLIENT)
  path = "boxscoretraditionalv2?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 box score stats for a game

Examples:

stats = NBA::BoxScoreTraditional.team_stats(game: "0022400001")
stats.each { |s| puts "#{s.team_name}: #{s.pts} pts" }

Parameters:

  • the game ID or Game object

  • (defaults to: CLIENT)

    the API client to use

Returns:

  • a collection of team box score stats

API:

  • public



40
41
42
43
# File 'lib/nba/box_score_traditional.rb', line 40

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