Module: NBA::CLI::Formatters::PlayerFormatters

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

Overview

Formatters for player-related output

Instance Method Summary collapse

Instance Method Details

#format_detailed_roster_player(player) ⇒ 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.

Formats a roster player with detailed information

Returns:

  • (String)


10
11
12
13
14
15
# File 'lib/nba/cli/formatters/player_formatters.rb', line 10

def format_detailed_roster_player(player)
  jersey = format_jersey_number(player.jersey_number)
  name = (player.full_name || "Unknown").ljust(25)
  position = format_position(player.position)
  "##{jersey} #{name} #{position} #{player.height || "?"}"
end

#format_draft_info(player) ⇒ 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.

Formats player draft information

Returns:

  • (String)


46
47
48
# File 'lib/nba/cli/formatters/player_formatters.rb', line 46

def format_draft_info(player)
  "#{player.draft_year} Round #{player.draft_round}, Pick #{player.draft_number}"
end

#format_jersey_number(number) ⇒ 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.

Formats a jersey number for display

Examples:

format_jersey_number(3) #=> " 3"

Returns:

  • (String)


23
# File 'lib/nba/cli/formatters/player_formatters.rb', line 23

def format_jersey_number(number) = number&.to_s&.rjust(2) || " ?"

#format_player_result(player) ⇒ 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.

Formats a player search result

Returns:

  • (String)


37
38
39
40
# File 'lib/nba/cli/formatters/player_formatters.rb', line 37

def format_player_result(player)
  status = player.active? ? "Active" : "Inactive"
  "#{player.full_name} (#{status})"
end

#format_position(position) ⇒ 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.

Formats a position abbreviation for display

Examples:

format_position(position) #=> "PG "

Returns:

  • (String)


31
# File 'lib/nba/cli/formatters/player_formatters.rb', line 31

def format_position(position) = (position&.abbreviation || "?").ljust(3)