Class: PpgLeaders::CLI
- Inherits:
-
Object
- Object
- PpgLeaders::CLI
- Defined in:
- lib/ppg_leaders/cli.rb
Overview
CLI controller
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
4 5 6 7 |
# File 'lib/ppg_leaders/cli.rb', line 4 def call list_leaders player_info end |
#exit_player ⇒ Object
38 39 40 |
# File 'lib/ppg_leaders/cli.rb', line 38 def exit_player puts "Come back and get more info on your favorite leading scorers" end |
#list_leaders ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/ppg_leaders/cli.rb', line 9 def list_leaders puts "Points Per Game Leaders for the Cavaliers" @players = PpgLeaders::Players.leaders @players.each.with_index(1) do |player, index| puts "#{index}. #{player.name} - #{player.jersey} - #{player.position}" end end |
#player_info ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ppg_leaders/cli.rb', line 18 def player_info input = nil while input != "exit" puts "Enter the number of the player you'd like to know more about, type list to see the list again or type exit:" input = gets.chomp if input.to_i == 1 || input.to_i == 2 || input.to_i == 3 the_player = @players[input.to_i-1] puts "#{the_player.name} - #{the_player.jersey} - #{the_player.position}" puts "#{the_player.more_info}" elsif input == "list" list_leaders elsif input == "exit" exit_player else puts "Not valid input enter list or exit" end end end |