class BookStoreRun
BookStoreRun
Class
Public Class Methods
start()
click to toggle source
# File lib/book_store_run.rb, line 5 def self.start book_store = BookStore.instance # puts commands to display instructions to the user puts 'Welcome to the Ruby Bookstore.' puts 'Please choose a follow operation from below to perform.' puts 'Type --1-- to add a new book' puts 'Type --2-- to find a book of your own choice' puts 'Type --3-- to have a list of all available books' puts 'Type --4-- to delete a book' # getting user's input choice = gets.chomp.downcase # performing what user wants case choice when '1' puts 'Enter the name of the book you want to add?' name = gets.chomp if book_store.book_exists(name.intern) puts 'Book already exists!' else puts 'Enter the rating of the book?' rating = gets.chomp book_store.book_add(name, rating) puts 'Book added to the store!' end when '2' puts 'Enter what you want to search?' search = gets.chomp book_store.book_search(search) when '3' then book_store.book_display when '4' puts 'Enter the name of the book you want to Delete?' name = gets.chomp if book_store.book_exists(name.intern) book_store.book_delete(name) else puts 'No Book Found' end else puts 'Didn\'t get what you are trying to ask!' end end