Module: NBA::TeamInfoCommon

Defined in:
lib/nba/team_info_common.rb

Overview

Provides methods to retrieve team information and season rankings

Constant Summary collapse

TEAM_INFO_COMMON =

Result set name for team info

Returns:

  • (String)

    the result set name

"TeamInfoCommon".freeze
TEAM_SEASON_RANKS =

Result set name for team season ranks

Returns:

  • (String)

    the result set name

"TeamSeasonRanks".freeze
AVAILABLE_SEASONS =

Result set name for available seasons

Returns:

  • (String)

    the result set name

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

  • team (Integer, Team)

    the team ID or Team object

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



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:

  • team (Integer, Team)

    the team ID or Team object

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

    the season year (defaults to current season)

  • season_type (String, nil) (defaults to: nil)

    the season type

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:

  • (TeamInfo, nil)

    the team information



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:

  • team (Integer, Team)

    the team ID or Team object

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

    the season year (defaults to current season)

  • season_type (String, nil) (defaults to: nil)

    the season type

  • client (Client) (defaults to: CLIENT)

    the API client to use

Returns:



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