Module: NBA::Standings

Defined in:
lib/nba/standings.rb

Overview

Provides methods to retrieve NBA standings

Class Method Summary collapse

Class Method Details

.all(season: Utils.current_season, client: CLIENT) ⇒ Collection

Retrieves all team standings

Examples:

standings = NBA::Standings.all
standings.each { |s| puts "#{s.conference_rank}. #{s.team_name}: #{s.wins}-#{s.losses}" }

Parameters:

  • 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:



18
19
20
21
# File 'lib/nba/standings.rb', line 18

def self.all(season: Utils.current_season, client: CLIENT)
  path = "leaguestandings?LeagueID=00&Season=#{Utils.format_season(season)}&SeasonType=Regular+Season"
  ResponseParser.parse(client.get(path)) { |data| build_standing(data) }
end

.conference(conference_name, season: Utils.current_season, client: CLIENT) ⇒ Collection

Retrieves standings for a specific conference

Examples:

western = NBA::Standings.conference("West")

Parameters:

  • conference_name (String)

    the conference name (East or West)

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

    the season year

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (Collection)

    a collection of standings for the conference



32
33
34
# File 'lib/nba/standings.rb', line 32

def self.conference(conference_name, season: Utils.current_season, client: CLIENT)
  Collection.new(all(season: season, client: client).select { |s| s.conference.eql?(conference_name) })
end