class Object

Public Instance Methods

choose_again() click to toggle source
# 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() click to toggle source
# File lib/cli.rb, line 13
def cli_printer
  puts "Welcome to 2019 GCPL table printer!"
  puts "Select a team to view:"
end
print() click to toggle source
table_printer(array) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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