Class: ScrapeGot::CLI

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

Instance Method Summary collapse

Instance Method Details

#display_lineObject



49
50
51
# File 'lib/scrape_got/cli.rb', line 49

def display_line
  puts "___________________________________\n".colorize(:light_yellow)
end

#display_menu_messageObject



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

def display_menu_message
  puts "Please enter a menu item number or type " + "exit".colorize(:red) + " to exit the program"
end

#end_programObject



53
54
55
56
# File 'lib/scrape_got/cli.rb', line 53

def end_program
  puts "Thanks for checking out I scrape and I know things, see ya soon!".colorize(:light_yellow)
  display_line
end

#greetingObject



31
32
33
# File 'lib/scrape_got/cli.rb', line 31

def greeting 
  puts "     ... Welcome to ...  \n  I scrape and I know things!\n   ".colorize(:light_yellow)
end


35
36
37
38
39
40
41
42
43
# File 'lib/scrape_got/cli.rb', line 35

def menu 
  display_line
  puts "Please choose an option: "
  puts "  1. List All Books\n  2. List 20 Houses\n  MENU\n  display_menu_message\nend\n"

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/scrape_got/cli.rb', line 6

def run
  system("clear")
  greeting
  Books.all_books
  Houses.all_houses
  
  @user_input = nil
  menu
    while @user_input != "exit"
      @user_input = gets.strip.downcase
        if @user_input == "1"
          puts "List Books:".colorize(:light_yellow)
          Books.print_books
          menu
        elsif @user_input == "2"
          puts "List Houses:".colorize(:light_yellow)
          Houses.print_houses
          menu
        else
          @user_input == "exit" ? break : display_menu_message
        end
      end
  end_program
end