Class: BookClubPicks::CLI

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

Overview

Our CLI Controller

Instance Method Summary collapse

Instance Method Details

#book_detailsObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/book_club_picks/cli.rb', line 96

def book_details
  puts "Title: #{@individual_details.name}"
  puts ""
  puts "------------------------------"
  puts ""
  puts "#{@individual_details.published}"
  puts ""
  puts "------------------------------"
  puts ""
  puts "#{@individual_details.clubs}"
  puts ""
  puts "------------------------------"
  puts ""
  puts "#{@individual_details.summary}"
  puts ""
  puts "------------------------------" 
end

#callObject



4
5
6
7
8
9
10
11
# File 'lib/book_club_picks/cli.rb', line 4

def call
  puts ""
  puts "Welcome to Book Club Picks.  You have come to the right place to find interesting books for your club to read. Browse through titles to find out more. Discover how many other clubs are currently reading that book!"
  puts ""
  puts "------------------------------"
  puts ""
  top_ten
end

#goodbyeObject



114
115
116
117
118
119
120
121
122
# File 'lib/book_club_picks/cli.rb', line 114

def goodbye
  puts ""
  puts "------------------------------"
  puts ""
  puts "See you when you are ready for your next book!"
  puts ""
  puts "------------------------------"
  puts ""
end


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/book_club_picks/cli.rb', line 39

def menu
  input = nil
  while input != "exit"
    puts ""
    input = gets.strip.downcase
    puts ""
    puts "------------------------------"
    
    if input.to_i > 0
      case input
      when "1"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(0)
      book_details
      when "2"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(1)   
      book_details
      when "3"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(2)   
      book_details
      when "4"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(3)   
      book_details
      when "5"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(4)   
      book_details
      when "6"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(5)  
      book_details
      when "7"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(6)   
      book_details
      when "8"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(7)   
      book_details
      when "9"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(8)   
      book_details
      when "10"
      puts ""
      @individual_details = BookClubPicks::Book.scrape_details(9)   
      book_details
      end 
    elsif input == "exit"
      goodbye 
    end
  end
end

#puts_booksObject



32
33
34
35
36
37
# File 'lib/book_club_picks/cli.rb', line 32

def puts_books
  current_books = BookClubPicks::Scraper.today
  current_books.each_with_index do |book, index|
    puts "#{index+1}. #{book}"
  end
end

#top_tenObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/book_club_picks/cli.rb', line 13

def top_ten
  puts "Here are this week's top 10 books."
  puts "They are ranked in order of their current popularity on the Book Movement website."
  puts ""
  puts "------------------------------"
  puts ""
  puts_books
  puts ""
  puts "------------------------------"
  puts ""
  puts "Which book would you like to learn more about?"
  puts "Enter 1-10 to read more information about each title."
  puts "Enter exit when you are finished browsing."
  puts ""
  puts "------------------------------"
  puts ""
  menu
end