Module: NBA::LeagueStandings

Defined in:
lib/nba/league_standings.rb

Overview

Provides methods to retrieve league standings with extended data

Constant Summary collapse

STANDINGS =

Result set name for standings

Returns:

  • (String)

    the result set name

"Standings".freeze
REGULAR_SEASON =

Season type constant for regular season

Returns:

  • (String)

    the season type

"Regular Season".freeze

Class Method Summary collapse

Class Method Details

.all(season: Utils.current_season, season_type: REGULAR_SEASON, league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves all league standings

Examples:

standings = NBA::LeagueStandings.all(season: 2024)
standings.each { |s| puts "#{s.playoff_rank}. #{s.full_name}: #{s.wins}-#{s.losses}" }

Parameters:

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

    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 (default NBA)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



30
31
32
33
34
35
# File 'lib/nba/league_standings.rb', line 30

def self.all(season: Utils.current_season, season_type: REGULAR_SEASON, league: League::NBA, client: CLIENT)
  league_id = Utils.extract_league_id(league)
  path = build_path(season, season_type, league_id)
  response = client.get(path)
  parse_response(response)
end

.conference(conference_name, season: Utils.current_season, season_type: REGULAR_SEASON, league: League::NBA, client: CLIENT) ⇒ Collection

Retrieves standings for a specific conference

Examples:

west = NBA::LeagueStandings.conference("West", season: 2024)
west.each { |s| puts "#{s.playoff_rank}. #{s.full_name}" }

Parameters:

  • conference_name (String)

    the conference name (“East” or “West”)

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

    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 (default NBA)

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



49
50
51
52
53
54
# File 'lib/nba/league_standings.rb', line 49

def self.conference(conference_name, season: Utils.current_season, season_type: REGULAR_SEASON, league: League::NBA,
  client: CLIENT)
  all_standings = all(season: season, season_type: season_type, league: league, client: client)
  filtered = all_standings.select { |s| s.conference.eql?(conference_name) }
  Collection.new(filtered)
end