Module: NBA::PlayerCareerStats

Defined in:
lib/nba/player_career_stats.rb

Overview

Provides methods to retrieve player career statistics

Constant Summary collapse

PER_GAME =

Regular season per game stats type

Returns:

  • (String)

    the per mode

"PerGame".freeze
TOTALS =

Totals stats type

Returns:

  • (String)

    the per mode

"Totals".freeze
RESULT_SET_NAME =

Result set name for regular season stats

Returns:

  • (String)

    the result set name

"SeasonTotalsRegularSeason".freeze

Class Method Summary collapse

Class Method Details

.find(player:, per_mode: PER_GAME, client: CLIENT) ⇒ Collection

Retrieves career statistics for a player

Examples:

stats = NBA::PlayerCareerStats.find(player: 201939)
stats.each { |s| puts "#{s.season_id}: #{s.pts} PPG" }

Parameters:

  • player (Integer, Player)

    the player ID or Player object

  • per_mode (String) (defaults to: PER_GAME)

    the per mode (PerGame, Totals)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of career stats by season



31
32
33
34
35
36
37
# File 'lib/nba/player_career_stats.rb', line 31

def self.find(player:, per_mode: PER_GAME, client: CLIENT)
  player_id = Utils.extract_id(player)
  path = "playercareerstats?PlayerID=#{player_id}&PerMode=#{per_mode}"
  ResponseParser.parse(client.get(path), result_set: RESULT_SET_NAME) do |data|
    build_career_stats(data, player_id)
  end
end