Module: NBA::HustleStatsBoxScore

Defined in:
lib/nba/hustle_stats_box_score.rb

Overview

Provides methods to retrieve hustle statistics for a game via hustlestatsboxscore endpoint

Constant Summary collapse

HUSTLE_STATS_AVAILABLE =

Result set name for availability status

Returns:

  • (String)

    the result set name

"HustleStatsAvailable".freeze
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
ENDPOINT =

API endpoint path

Returns:

  • (String)

    the endpoint path

"hustlestatsboxscore".freeze

Class Method Summary collapse

Class Method Details

.available?(game:, client: CLIENT) ⇒ Boolean

Checks if hustle stats are available for a game

Examples:

NBA::HustleStatsBoxScore.available?(game: "0022400001") #=> true

Parameters:

  • game (String, Game)

    the game ID or Game object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Boolean)

    true if hustle stats are available



61
62
63
64
# File 'lib/nba/hustle_stats_box_score.rb', line 61

def self.available?(game:, client: CLIENT)
  game_id = Utils.extract_id(game)
  stats_available?(client.get("#{ENDPOINT}?GameID=#{game_id}"))
end

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

Retrieves hustle statistics for players in a game

Examples:

stats = NBA::HustleStatsBoxScore.player_stats(game: "0022400001")

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 hustle stats



35
36
37
38
# File 'lib/nba/hustle_stats_box_score.rb', line 35

def self.player_stats(game:, client: CLIENT)
  game_id = Utils.extract_id(game)
  parse_stats(client.get("#{ENDPOINT}?GameID=#{game_id}"), game_id, PLAYER_STATS, :build_player_stat)
end

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

Retrieves hustle statistics for teams in a game

Examples:

stats = NBA::HustleStatsBoxScore.team_stats(game: "0022400001")

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 hustle stats



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

def self.team_stats(game:, client: CLIENT)
  game_id = Utils.extract_id(game)
  parse_stats(client.get("#{ENDPOINT}?GameID=#{game_id}"), game_id, TEAM_STATS, :build_team_stat)
end