class Cli
Public Class Methods
goodbye()
click to toggle source
# File lib/hockey_orgs/cli.rb, line 120 def self.goodbye puts "" puts "Thank you for your interest in the NHL, it was an honor to serve you." end
hello()
click to toggle source
# File lib/hockey_orgs/cli.rb, line 114 def self.hello puts "Hello and welcome to Hockey Orgs! Below you will find a list of all active NHL franchises:" puts " " end
more_info()
click to toggle source
# File lib/hockey_orgs/cli.rb, line 98 def self.more_info puts "Would you like more info on The #{Org.all[@i].name}?(Please type Y or N)" input = gets.chomp case input when 'y' self.org_options(@i) when 'n' Scraper.list_orgs self.org_menu else puts "Invalid input! Please type Y or N" self.more_info end end
org_choice()
click to toggle source
# File lib/hockey_orgs/cli.rb, line 69 def self.org_choice choice = gets.chomp case choice when "exit" puts "" puts "returning you to main menu" Scraper.list_orgs Cli.org_menu when '1' Org.get_arena(@i) puts "" self.more_info when '2' Org.get_founding(@i) sleep(0.8) self.same_founding(@i) when '3' Org.get_division(@i) puts "" self.more_info else #binding.pry puts "" puts "Invalid input" puts "" self.org_options(@i) end end
org_options(i)
click to toggle source
# File lib/hockey_orgs/cli.rb, line 31 def self.org_options(i) #provide options for learning about the organization name = Org.all[@i].name puts "What would you like to know about the #{name}?(type exit to return to team selection)" puts '' puts "1. Arena Name 2. Year of founding 3. What division do they play in?" self.org_choice end
same_founding(input)
click to toggle source
# File lib/hockey_orgs/cli.rb, line 39 def self.same_founding(input) #check if other teams were founded the same year teams = [] arr = [] puts "Would you like to see all other teams founded that year?(please type Y or N)" input = gets.chomp.downcase case input when 'y' Org.all.each do |o| if o.founding == Org.all[@i].founding && o.name != Org.all[@i].name arr << o.name end end if arr.size > 0 puts arr else #binding.pry puts "The #{Org.all[@i].name} were the only team founded in #{Org.all[@i].founding}" end self.more_info when 'n' self.more_info else puts "" puts "Invalid input" puts "" self.same_founding(@i) end end
Public Instance Methods
call()
click to toggle source
# File lib/hockey_orgs/cli.rb, line 4 def call Scraper.create_orgs Cli.hello Scraper.list_orgs Cli.org_menu end