class MLBScoreboard::CLI
Public Instance Methods
box_score(user_input)
click to toggle source
# File lib/cli.rb, line 40 def box_score(user_input) user_input = user_input.to_i - 1 teams = MLBScoreboard::Matchups.scrape_teams(user_input) runs = MLBScoreboard::Matchups.scrape_runs(user_input) hits = MLBScoreboard::Matchups.scrape_hits(user_input) errors = MLBScoreboard::Matchups.scrape_errors(user_input) home_line = [teams[0], runs[0], hits[0], errors[0]] away_line = [teams[1], runs[1], hits[1], errors[1]] rows = [] rows << home_line rows << away_line table = Terminal::Table.new :headings => ['Team', 'R', 'H', 'E'], :rows => rows puts table puts "\nWould you like to see the list again or exit?" user_input = gets.strip if user_input == "exit" exit else menu end end
goodbye()
click to toggle source
# File lib/cli.rb, line 68 def goodbye puts "*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*" puts "*~* Thanks for using Scoreboard *~*" puts "*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*" end
list_games()
click to toggle source
# File lib/cli.rb, line 32 def list_games puts "\nYesterday's Games Around the MLB" @matchups = MLBScoreboard::Matchups.today @matchups.each.with_index(1) do |matchup, index| puts "#{index}. #{matchup}" end end
start()
click to toggle source
# File lib/cli.rb, line 3 def start welcome menu goodbye end
welcome()
click to toggle source
# File lib/cli.rb, line 9 def welcome puts "*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*" puts "*~* Welcome to MLB Scoreboard *~*" puts "*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*" end