Class: Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/fish_finder/cli.rb

Instance Method Summary collapse

Instance Method Details



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fish_finder/cli.rb', line 16

def menu
  puts "Please pick from this commonly caught fish list:"
  input = gets.chomp
  if input.to_i == 0 || input.to_i > Fish.all.length
    puts "invalid choice, please choose again"
  else 
  fish = Fish.all[input.to_i - 1]
  # options for user  
    puts "Here is some info: #{fish.description}"
  end
  menu
end

#runObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/fish_finder/cli.rb', line 4

def run
  
  puts "Did you catch a fish off the coast of New England? What type do you think? Please pick from this commonly caught list..."
  Scraper.scrape_rt
  
  Fish.all.each.with_index(1) do | fish, i|
    puts "#{i}. #{fish.name}"
      
  end
  menu
end