class BookwormBuddy::CLI

Public Instance Methods

bestsellers() click to toggle source
# File lib/bookworm_buddy/cli.rb, line 45
def bestsellers
    input = gets.strip 
    if input.to_i.between?(1, 50)
        BookwormBuddy::Scraper.get_books_by_category(input)
        if BookwormBuddy::Book::ALL.empty?
            puts "\n""So sorry, that category seems to be empty at the moment. Please try another category!".colorize(:red)
            bestsellers
        else
        BookwormBuddy::Book.list_books_by_category(input)
        puts "\n""----------------------------------------".colorize(:cyan)
        puts "\n""To see the summary of a title that interests you, enter that number below. Otherwise, enter 'list' to return to the list of categories, or 'exit' to exit.".colorize(:green)
        puts "\n""----------------------------------------""\n".colorize(:cyan)
        description
        end
    elsif input == "list" 
        list
    elsif input == "exit"
        exit
    else 
        puts "\n"".... I am not sure what you meant (neither are the gnomes). Try again?".colorize(:red)
        bestsellers
    end
end
call() click to toggle source
# File lib/bookworm_buddy/cli.rb, line 3
def call
    puts "\n""--------------------------------------------".colorize(:cyan)
    puts "\n""       Welcome to the Bookworm Buddy!       ".colorize(:green)
    puts "\n""--------------------------------------------".colorize(:cyan)
    puts "         .--.                   .---.     "
    puts "     .---|__|           .-.     |~~~|     "
    puts "  .--|===|--|      _    |_|     |~~~|--.  "
    puts "  |  |===|  |     / .---!~|  .--|   |--|  "
    puts "  |%%|   |  |    /  |===| |--|%%|   |  |  "
    puts "  |%%|   |  |   /.'/|   | |__|  |   |  |  "
    puts "  |  |   |  |  /  / |===| |==|  |   |  |  "
    puts "  |  |   |__| /.'/  |   |_|__|  |~~~|__|  "
    puts "  |  |===|--|/.'/   |===|~|--|%%|~~~|--|  "
    puts "  ^--^---'--^`-^    ^---^-^--^--^---'--'  "
    puts "\n""--------------------------------------------"
    puts "\n""We bring you the top 20 Barnes & Noble bestselling books in the category of your choice," "\n" "so you can spend less time searching and more time reading!".colorize(:green)
    puts "\n""Give us one moment to awaken the book gnomes.".colorize(:magenta)
    BookwormBuddy::Scraper.get_categories
    main_menu
end
description() click to toggle source
# File lib/bookworm_buddy/cli.rb, line 69
def description
    input = gets.strip
    if input.to_i.between?(1, 20)
        BookwormBuddy::Scraper.get_description(input)
        puts "\n""----------------------------------------".colorize(:cyan)
        puts "\n""To see another book, enter that number below. Otherwise, enter 'list' to return to the list of categories, or 'exit' to exit.".colorize(:green)
        puts "\n""----------------------------------------""\n".colorize(:cyan)
        description
    elsif input == "list"
        list
    elsif input == "exit" 
        exit 
    else 
        puts ".... I am not sure what you meant (neither are the gnomes). Try again?".colorize(:red)
        description
    end
end
exit() click to toggle source
# File lib/bookworm_buddy/cli.rb, line 87
def exit
    puts "We hope you found what you were looking for.".colorize(:yellow)
    puts "\n""       ,   ,    "
    puts "      /////|    "
    puts "     ///// |    "
    puts "    |~~~|  |    "
    puts "    |===|  |    "
    puts "    |b  |  |    "
    puts "    | y |  |    "
    puts "    |  e| /     "
    puts "    |===|/      "
    puts "    '---'       "
    puts "\n""Happy reading!".colorize(:yellow)
end
list() click to toggle source
# File lib/bookworm_buddy/cli.rb, line 37
def list
    BookwormBuddy::Category.list_categories
    puts "\n""----------------------------------------".colorize(:cyan)
    puts "\n""To see the top 20 bestsellers in a category, enter the category number below.".colorize(:green)
    puts "\n""----------------------------------------""\n".colorize(:cyan)
    bestsellers
end
main_menu() click to toggle source