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
-
#format_detailed_roster_player(player) ⇒ String
private
Formats a roster player with detailed information.
-
#format_draft_info(player) ⇒ String
private
Formats player draft information.
-
#format_jersey_number(number) ⇒ String
private
Formats a jersey number for display.
-
#format_player_result(player) ⇒ String
private
Formats a player search result.
-
#format_position(position) ⇒ String
private
Formats a position abbreviation for display.
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
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
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
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
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
31 |
# File 'lib/nba/cli/formatters/player_formatters.rb', line 31 def format_position(position) = (position&.abbreviation || "?").ljust(3) |