Class: MicroGreens::CLI

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

Overview

CLI controller

Instance Method Summary collapse

Instance Method Details

#callObject



9
10
11
12
13
14
15
# File 'lib/micro_greens/cli.rb', line 9

def call
  puts "Who wants to eat some salad?".colorize(:green)
  puts "Our most popular micro greens are:".colorize(:green)
  scraper.list_greens
  menu
  goodbye
end

#goodbyeObject



45
46
47
# File 'lib/micro_greens/cli.rb', line 45

def goodbye
  puts "Enjoy your salad!".colorize(:green)
end

#htmlObject



17
18
19
# File 'lib/micro_greens/cli.rb', line 17

def html
  Nokogiri::HTML(open("http://www.johnnyseeds.com/vegetables/micro-greens"))
end


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/micro_greens/cli.rb', line 21

def menu
  puts "Type in the number corresponding to the micro green you would like to learn about.".colorize(:green)
  puts "When you are done learning, type '0' to exit.".colorize(:green)
  input = gets.to_i

  if input <= 18 && input > 0
    puts "Micro Green:".colorize(:green)
    puts scraper.name(input)
    puts "Description:".colorize(:green)
    puts scraper.description_one(input)
    puts scraper.description_two(input)
    puts "Days to maturity:".colorize(:green)
    puts scraper.maturity(input)
    puts "Growing information:".colorize(:green)
    puts scraper.grow_info(input)
    menu
  elsif input == 0
  else
    puts "Sorry, we do not have information about that micro green. Do try again!".colorize(:green)
    menu
  end

end

#scraperObject



5
6
7
# File 'lib/micro_greens/cli.rb', line 5

def scraper
  @scraper = MicroGreens::Scraper.new
end