Module: NBA::BoxScoreUsageV3

Defined in:
lib/nba/box_score_usage_v3.rb

Overview

Provides methods to retrieve usage box score statistics using V3 API

Constant Summary collapse

BOX_SCORE_KEY =

Returns JSON key for usage box score data.

Returns:

  • (String)

    JSON key for usage box score data

"boxScoreUsage".freeze
PLAYER_STATS =

Returns JSON key for player statistics.

Returns:

  • (String)

    JSON key for player statistics

"PlayerStats".freeze
TEAM_STATS =

Returns JSON key for team statistics.

Returns:

  • (String)

    JSON key for team statistics

"TeamStats".freeze

Class Method Summary collapse

Class Method Details

.player_stats(game:, start_period: 0, end_period: 0, client: CLIENT) ⇒ Collection

Retrieves usage player box score stats for a game

Examples:

stats = NBA::BoxScoreUsageV3.player_stats(game: "0022400001")
stats.each { |stat| puts "#{stat.player_name}: #{stat.usg_pct}" }

Parameters:

  • game (String, Integer)

    the game ID

  • start_period (Integer) (defaults to: 0)

    the starting period

  • end_period (Integer) (defaults to: 0)

    the ending period

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of player usage stats



30
31
32
33
34
# File 'lib/nba/box_score_usage_v3.rb', line 30

def self.player_stats(game:, start_period: 0, end_period: 0, client: CLIENT)
  game_id = Utils.extract_id(game)
  response = client.get(build_path(game_id, start_period, end_period))
  parse_player_response(response, game_id)
end

.team_stats(game:, start_period: 0, end_period: 0, client: CLIENT) ⇒ Collection

Retrieves usage team box score stats for a game

Examples:

stats = NBA::BoxScoreUsageV3.team_stats(game: "0022400001")
stats.each { |stat| puts "#{stat.team_abbreviation}: #{stat.usg_pct}" }

Parameters:

  • game (String, Integer)

    the game ID

  • start_period (Integer) (defaults to: 0)

    the starting period

  • end_period (Integer) (defaults to: 0)

    the ending period

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of team usage stats



47
48
49
50
51
# File 'lib/nba/box_score_usage_v3.rb', line 47

def self.team_stats(game:, start_period: 0, end_period: 0, client: CLIENT)
  game_id = Utils.extract_id(game)
  response = client.get(build_path(game_id, start_period, end_period))
  parse_team_response(response, game_id)
end