Module: NBA::TeamHistoricalLeaders

Defined in:
lib/nba/team_historical_leaders.rb

Overview

Provides methods to retrieve team historical career leaders

Constant Summary collapse

RESULT_SET_NAME =

Result set name in API response

Returns:

  • (String)

    the result set name

"CareerLeadersByTeam".freeze

Class Method Summary collapse

Class Method Details

.find(team:, season: Utils.current_season, client: CLIENT) ⇒ TeamHistoricalLeader?

Retrieves historical leaders for a team

Examples:

leaders = NBA::TeamHistoricalLeaders.find(team: 1610612744)
leaders.pts_player #=> "Stephen Curry"

Parameters:

  • team (Integer, Team)

    the team or team ID

  • season (Integer) (defaults to: Utils.current_season)

    the season year (defaults to current season)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



25
26
27
28
29
30
31
# File 'lib/nba/team_historical_leaders.rb', line 25

def self.find(team:, season: Utils.current_season, client: CLIENT)
  id = Utils.extract_id(team)
  return unless id

  path = build_path(id, season)
  ResponseParser.parse_single(client.get(path), result_set: RESULT_SET_NAME) { |data| build_leader(data) }
end