Module: NBA::CumeStatsPlayer

Defined in:
lib/nba/cume_stats_player.rb

Overview

Provides methods to retrieve cumulative player statistics

Defined Under Namespace

Modules: GameAttributes, TotalAttributes

Constant Summary collapse

GAME_BY_GAME_STATS =

Result set name for game-by-game stats

Returns:

  • (String)

    the result set name

"GameByGameStats".freeze
TOTAL_PLAYER_STATS =

Result set name for total player stats

Returns:

  • (String)

    the result set name

"TotalPlayerStats".freeze

Class Method Summary collapse

Class Method Details

.find(player:, game_ids:, season:, season_type: "Regular Season", league: League::NBA, client: CLIENT) ⇒ Hash?

Retrieves cumulative player statistics for specific games

Examples:

stats = NBA::CumeStatsPlayer.find(
  player: 201939,
  game_ids: ["0022400001", "0022400002"],
  season: "2024-25",
  season_type: "Regular Season"
)
stats[:game_by_game].each { |g| puts "#{g.game_date}: #{g.pts} PTS" }
puts "Total: #{stats[:total].pts} PTS"

Parameters:

  • player (Integer, Player)

    the player ID or Player object

  • game_ids (Array<String>, String)

    game IDs as array or pipe-separated string

  • season (String)

    the season (e.g., “2024-25”)

  • season_type (String) (defaults to: "Regular Season")

    the season type (default “Regular Season”)

  • league (String, League) (defaults to: League::NBA)

    the league ID or League object (default NBA)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Hash, nil)

    hash with :game_by_game and :total keys, or nil



39
40
41
42
43
44
45
46
47
48
# File 'lib/nba/cume_stats_player.rb', line 39

def self.find(player:, game_ids:, season:, season_type: "Regular Season", league: League::NBA, client: CLIENT)
  player_id = Utils.extract_id(player)
  league_id = Utils.extract_league_id(league)
  game_ids_param = format_game_ids(game_ids)

  path = "cumestatsplayer?PlayerID=#{player_id}&GameIDs=#{game_ids_param}" \
         "&LeagueID=#{league_id}&Season=#{season}&SeasonType=#{season_type}"
  response = client.get(path)
  parse_response(response)
end