Module: NBA::TeamInfoCommon

Defined in:
lib/nba/team_info_common.rb

Overview

Provides methods to retrieve team information and season rankings

API:

  • public

Constant Summary collapse

TEAM_INFO_COMMON =

Result set name for team info

Returns:

  • the result set name

API:

  • public

"TeamInfoCommon".freeze
TEAM_SEASON_RANKS =

Result set name for team season ranks

Returns:

  • the result set name

API:

  • public

"TeamSeasonRanks".freeze
AVAILABLE_SEASONS =

Result set name for available seasons

Returns:

  • the result set name

API:

  • public

"AvailableSeasons".freeze

Class Method Summary collapse

Class Method Details

.available_seasons(team:, client: CLIENT) ⇒ Collection

Retrieves available seasons for a team

Examples:

seasons = NBA::TeamInfoCommon.available_seasons(team: NBA::Team::GSW)
seasons.each { |s| puts s }

Parameters:

  • the team ID or Team object

  • (defaults to: CLIENT)

    the API client to use

Returns:

  • a collection of season IDs

API:

  • public



68
69
70
71
72
# File 'lib/nba/team_info_common.rb', line 68

def self.available_seasons(team:, client: CLIENT)
  path = build_path(team, nil, nil)
  response = client.get(path)
  parse_seasons_response(response)
end

.find(team:, season: Utils.current_season, season_type: nil, client: CLIENT) ⇒ TeamInfo?

Retrieves team information

Examples:

info = NBA::TeamInfoCommon.find(team: NBA::Team::GSW)
puts "#{info.team_city} #{info.team_name}: #{info.w}-#{info.l}"

Parameters:

  • the team ID or Team object

  • (defaults to: Utils.current_season)

    the season year (defaults to current season)

  • (defaults to: nil)

    the season type

  • (defaults to: CLIENT)

    the API client to use

Returns:

  • the team information

API:

  • public



36
37
38
39
40
# File 'lib/nba/team_info_common.rb', line 36

def self.find(team:, season: Utils.current_season, season_type: nil, client: CLIENT)
  path = build_path(team, season, season_type)
  response = client.get(path)
  parse_info_response(response)
end

.ranks(team:, season: Utils.current_season, season_type: nil, client: CLIENT) ⇒ TeamSeasonRank?

Retrieves team season rankings

Examples:

ranks = NBA::TeamInfoCommon.ranks(team: NBA::Team::GSW)
puts "Points rank: #{ranks.pts_rank} (#{ranks.pts_pg} PPG)"

Parameters:

  • the team ID or Team object

  • (defaults to: Utils.current_season)

    the season year (defaults to current season)

  • (defaults to: nil)

    the season type

  • (defaults to: CLIENT)

    the API client to use

Returns:

  • the team season rankings

API:

  • public



53
54
55
56
57
# File 'lib/nba/team_info_common.rb', line 53

def self.ranks(team:, season: Utils.current_season, season_type: nil, client: CLIENT)
  path = build_path(team, season, season_type)
  response = client.get(path)
  parse_ranks_response(response)
end