4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/childrens_books/cli.rb', line 4
def call
ChildrensBooks::Scraper.scrape
puts ""
puts "Welcome to the Children's Books Database!".magenta
puts ""
@input = nil
while @input != "exit"
@input = gets.chomp
if @input == "1"
puts "Here are some books 2-4 year olds will love:".green
books_array = ChildrensBooks::Book.preschoolbooks
print_books(books_array)
puts "Enter 'menu' for more options or 'exit' to leave the program.".green
elsif @input == "2"
puts "Here are some books 5-7 year olds will love:".green
books_array = ChildrensBooks::Book.littlekidbooks
print_books(books_array)
puts "Enter 'menu' for more options or 'exit' to leave the program.".green
elsif @input == "3"
puts "Here are some books 8-9 year olds will love:".green
books_array = ChildrensBooks::Book.bigkidbooks
print_books(books_array)
puts "Enter 'menu' for more options or 'exit' to leave the program.".green
elsif @input == "4"
puts "Here are some books 10-12 year olds will love:".green
books_array = ChildrensBooks::Book.tweenbooks
print_books(books_array)
puts "Enter 'menu' for more options or 'exit' to leave the program.".green
elsif @input == "5"
puts "Here's a randomly selected book for you to try:".green
book_obj = ChildrensBooks::Book.all.sample
print_book(book_obj)
puts "Enter 'menu' for more options or 'exit' to leave the program.".green
elsif @input == "menu"
elsif @input == "exit"
break
else
puts "Sorry, you did not select a valid number. Please try again.".red
puts ""
end
end
puts "Thanks for visiting. I hope you're headed out to the bookstore!".magenta
end
|