Module: NBA::CumeStatsTeam

Defined in:
lib/nba/cume_stats_team.rb

Overview

Provides methods to retrieve cumulative team statistics

Defined Under Namespace

Modules: PlayerAttributes, 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_TEAM_STATS =

Result set name for total team stats

Returns:

  • (String)

    the result set name

"TotalTeamStats".freeze

Class Method Summary collapse

Class Method Details

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

Retrieves cumulative team statistics for specific games

Examples:

result = NBA::CumeStatsTeam.find(team: 1610612744, game_ids: ["0022400001", "0022400002"], season: 2024)
result[:game_by_game].each { |p| puts "#{p.player_name}: #{p.pts} pts" }
result[:total].pts #=> 220

Parameters:

  • team (Integer, Team)

    the team ID or Team object

  • game_ids (Array<String>, String)

    game IDs (array or pipe-separated string)

  • season (Integer)

    the season year

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

    the season type

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

    the league ID or League object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Hash, nil)

    hash with :game_by_game (Collection) and :total (CumeStatsTeamTotal) keys, or nil



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/nba/cume_stats_team.rb', line 33

def self.find(team:, game_ids:, season:, season_type: "Regular Season", league: League::NBA, client: CLIENT)
  team_id = Utils.extract_id(team)
  return unless team_id

  game_ids_str = normalize_game_ids(game_ids)
  return unless game_ids_str

  path = build_path(team_id, game_ids_str, season, season_type, league)
  response = client.get(path)
  parse_response(response)
end