Module: NBA::TeamYearByYearStats

Defined in:
lib/nba/team_year_by_year_stats.rb

Overview

Provides methods to retrieve team year-by-year statistics

Constant Summary collapse

TEAM_STATS =

Result set name for team stats

Returns:

  • (String)

    the result set name

"TeamStats".freeze
REGULAR_SEASON =

Season type constant for regular season

Returns:

  • (String)

    the season type

"Regular Season".freeze
PLAYOFFS =

Season type constant for playoffs

Returns:

  • (String)

    the season type

"Playoffs".freeze
PER_GAME =

Per mode constant for per game stats

Returns:

  • (String)

    the per mode

"PerGame".freeze
TOTALS =

Per mode constant for totals

Returns:

  • (String)

    the per mode

"Totals".freeze

Class Method Summary collapse

Class Method Details

.find(team:, season_type: REGULAR_SEASON, per_mode: PER_GAME, client: CLIENT) ⇒ Collection

Retrieves year-by-year statistics for a team

Examples:

stats = NBA::TeamYearByYearStats.find(team: NBA::Team::GSW)
stats.each { |s| puts "#{s.year}: #{s.wins}-#{s.losses}" }

Parameters:

  • team (Integer, Team)

    the team ID or Team object

  • season_type (String) (defaults to: REGULAR_SEASON)

    the season type

  • per_mode (String) (defaults to: PER_GAME)

    the per mode

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of year-by-year stats



41
42
43
44
45
46
# File 'lib/nba/team_year_by_year_stats.rb', line 41

def self.find(team:, season_type: REGULAR_SEASON, per_mode: PER_GAME, client: CLIENT)
  team_id = extract_team_id(team)
  path = build_path(team_id, season_type, per_mode)
  response = client.get(path)
  parse_response(response)
end