class NPRBestBooks::CLI

Attributes

current_book_id[RW]
list[RW]
year[RW]

Public Instance Methods

bookreview_linewrap(string, linewrap_length = 75) click to toggle source
# File lib/npr_best_books/cli.rb, line 127
def bookreview_linewrap(string, linewrap_length = 75)
  string_wrapped = string.scan(/\S.{0,#{linewrap_length}}\S(?=\s|$)|\S+/)
  string_wrapped.each {|line| puts "   " + "#{line}"}
end
call() click to toggle source
# File lib/npr_best_books/cli.rb, line 4
def call
  latest_year = NPRBestBooks::List.all_years.last
  @year = latest_year
  @current_book_id = ""
  welcome
  list_books
  menu
end
goodbye() click to toggle source
# File lib/npr_best_books/cli.rb, line 132
def goodbye
  puts "Thank you for checking out NPR's Book Concierge. Goodbye!"
  exit
end
list_books() click to toggle source
# File lib/npr_best_books/cli.rb, line 18
def list_books
  if @list
    puts "\r#{@year}'s Science Fiction & Fantasy recommendations:"
    @list = NPRBestBooks::List.science_fiction_and_fantasy
    puts "Total #{@year} NPR Science Fiction & Fantasy recommendations: #{@list.count} books"
  else
    NPRBestBooks::List.latest
    puts "\r#{@year}'s Science Fiction & Fantasy recommendations:"
    @list = NPRBestBooks::List.science_fiction_and_fantasy
    puts "Total #{@year} NPR Science Fiction & Fantasy recommendations: #{@list.count} books"
  end
end
menu() click to toggle source
sub_menu() click to toggle source
welcome() click to toggle source
# File lib/npr_best_books/cli.rb, line 13
def welcome
  puts "== Welcome to NPR's Book Concierge =="
  puts "== A Guide to #{@year}'s Great Reads =="
end