Module: NBA::BoxScoreAdvanced

Defined in:
lib/nba/box_score_advanced.rb

Overview

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

Examples:

stats = NBA::BoxScoreAdvanced.player_stats(game: "0022400001")
stats.each { |s| puts "#{s.player_name}: #{s.off_rating} ORTG" }

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 advanced box score stats



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

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

Examples:

stats = NBA::BoxScoreAdvanced.team_stats(game: "0022400001")
stats.each { |s| puts "#{s.team_name}: #{s.off_rating} ORTG" }

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 advanced box score stats



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

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