class KnicksHistory::CLI

Public Instance Methods

call() click to toggle source
# File lib/knicks_history/cli.rb, line 3
def call
  scraper = KnicksHistory::Scraper.new
  scraper.make_seasons
  puts "New York Knicks - Statistics by Season"
  start
end
output_best_player(season) click to toggle source
# File lib/knicks_history/cli.rb, line 63
def output_best_player(season)
  puts "\n\nBest Player(WS)\n#{season[1].best_player_ws}"
end
output_def_rtng(season) click to toggle source
# File lib/knicks_history/cli.rb, line 59
def output_def_rtng(season)
  puts "\n\nDef Rtng\n#{season[1].def_rating}"
end
output_off_rtng(season) click to toggle source
# File lib/knicks_history/cli.rb, line 55
def output_off_rtng(season)
  puts "\n\nOff Rtng\n#{season[1].off_rating}"
end
output_pace(season) click to toggle source
# File lib/knicks_history/cli.rb, line 67
def output_pace(season)
  puts "\n\nPace\n#{season[1].pace}"
end
output_playoff_results(season) click to toggle source
# File lib/knicks_history/cli.rb, line 71
def output_playoff_results(season)
  puts "\n\nPlayoff Results\n#{season[1].playoff_results}"
end
output_stats(season) click to toggle source
# File lib/knicks_history/cli.rb, line 48
def output_stats(season)
  #prints stats for that year
  puts "\n\nYear  Wins  Losses  Win%"
  #binding.pry
  puts "#{season[1].year}   #{season[1].wins}     #{season[1].losses}    #{season[1].win_percentage}"
end
start() click to toggle source
# File lib/knicks_history/cli.rb, line 10
def start
  input = ""
  while true
    puts "\nWhich season would you like to see stats for? (Enter a year between 1946-2017) or type exit."
    input = gets.strip
    year = input.to_i
    if year < 2018 && year > 1945
      season = KnicksHistory::Season.find_season(year)
      output_stats(season)
      while true
        puts "\nAdvanced Stats (enter the number of the statistic you want to see or type back)\n1. Offensive Rating\n2. Defensive Rating\n3. Best Player w/ Win Shares\n4. Offensive Pace\n5. Playoff Results"
        secondary_input = gets.strip
        case secondary_input
        when "1"
          output_off_rtng(season)
        when "2"
          output_def_rtng(season)
        when "3"
          output_best_player(season)
        when "4"
          output_pace(season)
        when "5"
          output_playoff_results(season)
        when "back"
          break
        else
          puts "\nSorry, must enter a number 1-3"
        end
      end
    elsif input == "exit"
      puts "\n\nThanks for using my gem! Go Knicks!"
      break
    else
      puts "\nSorry, no season found for that selection. Try again."
    end
  end
end