Module: NBA::CLI::Formatters::TeamFormatters

Included in:
NBA::CLI::Formatters
Defined in:
lib/nba/cli/formatters/team_formatters.rb

Overview

Formatters for team-related output

Constant Summary collapse

EAST =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Eastern Conference team abbreviations

Returns:

  • (Array<String>)
%w[ATL BOS BKN CHA CHI CLE DET IND MIA MIL NYK ORL PHI TOR WAS].freeze
DIVISIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Division mappings by team abbreviation

Returns:

  • (Hash)
{
  %w[BOS BKN NYK PHI TOR] => "Atlantic", %w[CHI CLE DET IND MIL] => "Central",
  %w[ATL CHA MIA ORL WAS] => "Southeast", %w[DEN MIN OKC POR UTA] => "Northwest",
  %w[GSW LAC LAL PHX SAC] => "Pacific", %w[DAL HOU MEM NOP SAS] => "Southwest"
}.freeze

Instance Method Summary collapse

Instance Method Details

#championship_year?(stat) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether the stat represents a championship year

Returns:

  • (Boolean)


61
62
63
# File 'lib/nba/cli/formatters/team_formatters.rb', line 61

def championship_year?(stat)
  stat.nba_finals_appearance.eql?("LEAGUE CHAMPION")
end

#conference_name(detail) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the conference name for a team

Returns:

  • (String)


36
37
38
# File 'lib/nba/cli/formatters/team_formatters.rb', line 36

def conference_name(detail)
  EAST.include?(detail.abbreviation.to_s) ? "Eastern Conference" : "Western Conference"
end

#division_for_team(abbr) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Looks up the division for a team abbreviation

Returns:

  • (String, nil)


52
53
54
55
# File 'lib/nba/cli/formatters/team_formatters.rb', line 52

def division_for_team(abbr)
  division = DIVISIONS.find { |teams, _| teams.include?(abbr) }&.last
  "#{division} Division" if division
end

#division_name(detail) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the division name for a team

Returns:

  • (String, nil)


44
45
46
# File 'lib/nba/cli/formatters/team_formatters.rb', line 44

def division_name(detail)
  division_for_team(detail.abbreviation.to_s)
end

#team_nickname(team) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the team nickname for display

Returns:

  • (String)


26
27
28
29
30
# File 'lib/nba/cli/formatters/team_formatters.rb', line 26

def team_nickname(team)
  return "TBD" unless team

  team.nickname || team.full_name&.split&.last || "TBD"
end