Top Level Namespace
Defined Under Namespace
Classes: Team
Instance Method Summary collapse
- #choose_again ⇒ Object
- #cli_printer ⇒ Object
- #print ⇒ Object
- #table_printer(array) ⇒ Object
- #team_array_build(array) ⇒ Object
- #team_selector ⇒ Object
Instance Method Details
#choose_again ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cli.rb', line 30 def choose_again puts "Would you like to see a new team? Y/N" input = gets.strip input = input.upcase if input == "Y" table_printer(@all_team_data_save) team_selector choose_again elsif input == "N" puts "Thank you!" else puts "Please select Y or N" choose_again end end |
#cli_printer ⇒ Object
13 14 15 16 |
# File 'lib/cli.rb', line 13 def cli_printer puts "Welcome to 2019 GCPL table printer!" puts "Select a team to view:" end |
#print ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/cli.rb', line 46 def print cli_printer table_printer(@all_team_data_save) team_array_build(@all_team_data_save) team_selector choose_again end |
#table_printer(array) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/cli.rb', line 4 def table_printer(array) counter = 0 array.map do |team| counter += 1 puts "#{counter}. #{team[0]}" end puts "Please select a team(1 - 18):" end |
#team_array_build(array) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/team.rb', line 26 def team_array_build(array) array.each do |team_data| team_name = team_data[0].strip games_played = team_data[1] wins = team_data[2] losses = team_data[3] draws = team_data[4] points = team_data[5] goals_for = team_data[6] goals_against = team_data[7] Team.new(team_name, games_played, wins, losses, draws, points, goals_for, goals_against) end end |
#team_selector ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cli.rb', line 18 def team_selector input = gets.strip.to_i input -= 1 if input <= 18 table = "Team Name: #{Team.all[input].team_name}\t Games Played: #{Team.all[input].games_played}\n Wins:#{Team.all[input].wins}\t Losses: #{Team.all[input].losses}\t Draws: #{Team.all[input].draws}\t Points: #{Team.all[input].points}\n Goals For: #{Team.all[input].goals_for}\t Goals Against: #{Team.all[input].goals_against}" puts table else puts "Please select a valid team" team_selector end end |