Module: NBA::BoxScoreTraditional

Defined in:
lib/nba/box_score_traditional.rb

Overview

Provides methods to retrieve traditional box score statistics

Constant Summary collapse

PLAYER_STATS =

Result set name for player stats

Returns:

  • (String)

    the result set name

"PlayerStats".freeze
TEAM_STATS =

Result set name for team stats

Returns:

  • (String)

    the result set name

"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:

  • game (String, Game)

    the game ID or Game object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of player box score stats



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:

  • game (String, Game)

    the game ID or Game object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of team box score stats



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