Class: MlsStandings::CLI
- Inherits:
-
Object
- Object
- MlsStandings::CLI
- Defined in:
- lib/mls_standings/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #east_team_record(input) ⇒ Object
- #eastern_conf ⇒ Object
- #start_menu ⇒ Object
- #west_team_record(input) ⇒ Object
- #western_conf ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 |
# File 'lib/mls_standings/cli.rb', line 3 def call MlsStandings::Scrapper.create_teams end |
#east_team_record(input) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/mls_standings/cli.rb', line 92 def east_team_record(input) system "clear" team = MlsStandings::Team.eastern_conf[input - 1] puts "#{team.name}".colorize(:blue) puts "***********************".colorize(:blue) puts "Games Played: #{team.games_played}" puts "Wins: #{team.wins}" puts "Losses: #{team.losses}" puts "Ties: #{team.ties}" puts "\n Type 'MLS' to restart CLI or 'e' to exit:" until input == 'e' || input == 'mls' input = gets.strip.downcase case input.downcase when "e" exit when "mls" else puts "Not Valid. Please select type 'MLS' or 'e': " end end end |
#eastern_conf ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mls_standings/cli.rb', line 36 def eastern_conf system "clear" puts " MLS Eastern Conference".colorize(:blue) puts " **********************".colorize(:blue) i = 1 teams= MlsStandings::Team.eastern_conf teams.each do |team| puts "#{i}. #{team.name}" i += 1 end puts "\nSelect 1-11 to get more information on the team, 's' to switch conference, or exit:" input = nil until input == 'et' || input == 's' || input.to_i.between?(1, 11) input = gets.strip.downcase case when input.to_i.between?(1, 11) east_team_record(input.to_i) when input.downcase == "s" western_conf when input.downcase == "e" exit else puts "Not a valid team. Please select a valid team or, 's' to switch or 'e' to exit: " end end end |
#start_menu ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mls_standings/cli.rb', line 8 def system "clear" puts " ***************".colorize(:blue) puts " *MLS Standings*".colorize(:red) puts " ***************".colorize(:blue) puts "\n1. Eastern Conference." puts "2. Western Conference.\n\n" puts "Enter '1' for the MLS Eastern Conference." puts "Enter '2' for the MLS Western Conference." puts "\nSelect a conference or type 'e' to exit: " input = nil until input == 'e' || input == '1' || input == '2' input = gets.strip.downcase case input.downcase when "1" eastern_conf when "2" western_conf when "e" exit else puts "Not Valid. Please select a conference: " end end end |
#west_team_record(input) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/mls_standings/cli.rb', line 116 def west_team_record(input) system "clear" team = MlsStandings::Team.western_conf[input - 1] puts "#{team.name}".colorize(:red) puts "***********************".colorize(:red) puts "Games Played: #{team.games_played}" puts "Wins: #{team.wins}" puts "Losses: #{team.losses}" puts "Ties: #{team.ties}" puts "\n Type 'MLS' to restart CLI or 'e' to exit:" until input == 'e' || input == 'mls' input = gets.strip.downcase case input.downcase when "e" exit when "mls" else puts "Not Valid. Please select type 'MLS' or 'exit': " end end end |
#western_conf ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/mls_standings/cli.rb', line 64 def western_conf system "clear" puts " MLS Western Conference".colorize(:red) puts " **********************".colorize(:red) i = 1 teams = MlsStandings::Team.western_conf teams.each do |team| puts "#{i}. #{team.name}" i += 1 end puts "\nSelect 1-11 to get more information on the team, 's' to switch conference, or exit:" input = nil until input == 'e' || input == 's'||input.to_i.between?(1, 12) input = gets.strip.downcase case when input.to_i.between?(1, 12) west_team_record(input.to_i) when input.downcase == "s" eastern_conf when input.downcase == "e" exit else puts "Not a valid team. Please select a valid team or, 's' or 'e': " end end end |