class AmazonBook::CLI

Public Instance Methods

cli_attribute(input_1) click to toggle source
# File lib/AmazonBook/cli.rb, line 52
def cli_attribute(input_1)
  while input_1.downcase != "exit"
    if input_1.to_i < AmazonBook::Scraper.scrape_list_page.length
      print_attribute(input_1)
      puts "Would you like to see another book?"
      input_1 = gets.strip
      cli_attribute(input_1)
    else
      puts "Input invalid. Please try again or type exit."
    end
  end
  puts "Thank you and hope to see you again!"
end
print_attribute(number) click to toggle source
print_list(number) click to toggle source
start() click to toggle source
# File lib/AmazonBook/cli.rb, line 3
def start
  puts "Welcome to Amazon Book Best Sellers Gem! Please enter the number of top Amazon books you'd like to see on the list:"

  input = gets.strip
  if input.to_i.is_a? Integer
    puts "Printing a list of #{input} books:"
    print_list(input)
  elsif input.downcase == "exit"
    puts "Thank you and hope to see you again!"
  else
    puts "Input invalid. Please input an integer or type exit."
  end

  puts "Would you like to learn more on any of the books in the list? Enter the number of the book, or exit."

  input_1 = gets.strip
  cli_attribute(input_1)
  # if input_1.to_i.is_a? Integer && input_1.to_i < input.to_i
  #   print_attribute(input_1)
  # elsif input.downcase == "exit"
  #   puts "Thank you and hope to see you again!"
  # else
  #   puts "Input invalid. Please try again or type exit."
  # end
end