Module: NBA::PlayerGameLog

Defined in:
lib/nba/player_game_log.rb

Overview

Provides methods to retrieve player game logs

Constant Summary collapse

REGULAR_SEASON =

Regular season type

Returns:

  • (String)

    the season type

"Regular Season".freeze
PLAYOFFS =

Playoffs season type

Returns:

  • (String)

    the season type

"Playoffs".freeze

Class Method Summary collapse

Class Method Details

.find(player:, season: Utils.current_season, season_type: REGULAR_SEASON, client: CLIENT) ⇒ Collection

Retrieves game logs for a player

Examples:

logs = NBA::PlayerGameLog.find(player: 201939)
logs.each { |log| puts "#{log.game_date}: #{log.pts} points" }

Parameters:

  • player (Integer, Player)

    the player ID or Player object

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

    the season year (defaults to current season)

  • season_type (String) (defaults to: REGULAR_SEASON)

    the season type (Regular Season, Playoffs)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



28
29
30
31
32
# File 'lib/nba/player_game_log.rb', line 28

def self.find(player:, season: Utils.current_season, season_type: REGULAR_SEASON, client: CLIENT)
  path = "playergamelog?PlayerID=#{Utils.extract_id(player)}&Season=#{Utils.format_season(season)}" \
         "&SeasonType=#{season_type}"
  ResponseParser.parse(client.get(path)) { |data| build_game_log(data) }
end