Class: BestBooks::CLI

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

Instance Method Summary collapse

Instance Method Details

#book_descriptions(input, book_input) ⇒ Object



20
21
22
# File 'lib/best_books/cli.rb', line 20

def book_descriptions(input, book_input)
	BestBooks::Decade.description(input, book_input.to_i)
end

#callObject



3
4
5
6
7
8
# File 'lib/best_books/cli.rb', line 3

def call
	puts "The Best Books!"
	list_decades
	menu
	goodbye
end

#goodbyeObject



56
57
58
# File 'lib/best_books/cli.rb', line 56

def goodbye
	puts "Ok, adios. I hope you're reading a book."
end

#list_decadesObject



10
11
12
13
# File 'lib/best_books/cli.rb', line 10

def list_decades
	@decade = BestBooks::Decade.print
	@decade
end


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
50
51
52
53
54
# File 'lib/best_books/cli.rb', line 24

def menu
	input = nil
	puts "Enter the number of the century for which you want to see the Top Books!"
	puts "Type 'list' to see the centuries again, or type 'exit'"
	while input != "exit"
		input = gets.strip.downcase
		if input.to_i > 0
			puts "Loading.... Here are the top 10 books of the"
			puts @decade[input.to_i-1].name
			topten(input)

			book_input = ""
			while book_input != "exit"
			puts "Type the number of the book to read the description, rating and more information."
			book_input = gets.strip.downcase
			if book_input.to_i > 0
				book_descriptions(input, book_input)
				puts "For information on another book, enter its number."
				puts "To see the top ten books for this decade, type 'top ten'"
			elsif book_input == "top ten"
				topten(input)
			end
			end
			
		elsif input == "list"
			list_decades
		else
			puts "Not sure what you mean by that. Try 'list' or 'exit'"
		end
	end
end

#topten(input) ⇒ Object



15
16
17
18
# File 'lib/best_books/cli.rb', line 15

def topten(input)
	#This takes over a minute to load and that's gotta change. 
	BestBooks::Decade.top10(input.to_i)
end