Class: BobaFinder::CLI
- Inherits:
-
Object
- Object
- BobaFinder::CLI
- Defined in:
- lib/boba_finder_CLI/cli.rb
Overview
The CLI controller
Instance Method Summary collapse
Instance Method Details
#bye ⇒ Object
60 61 62 |
# File 'lib/boba_finder_CLI/cli.rb', line 60 def bye puts "Goodbye" end |
#call ⇒ Object
3 4 5 6 |
# File 'lib/boba_finder_CLI/cli.rb', line 3 def call list end |
#list ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/boba_finder_CLI/cli.rb', line 8 def list input = "" puts "Welcome to Boba Finder!".colorize(:light_blue) sleep 1 BobaFinder::Finder.scrape_yelp BobaFinder::Boba.boba.each_with_index{|drink, i| puts "#{i + 1}. #{drink.name}"} puts "----------------------".colorize(:green) end |
#menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/boba_finder_CLI/cli.rb', line 17 def puts "Based on numbered order, what place would you like to get information about?".colorize(:light_blue) input = gets.strip.to_i if input > 10 puts "Invalid number! Please put 1 - 10.".colorize(:red) sleep 1 puts "----------------------".colorize(:green) self. else result(input) end end |
#result(input) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/boba_finder_CLI/cli.rb', line 30 def result(input) spot = BobaFinder::Boba.boba[input - 1] puts "#{spot.name}" puts "This place has a #{spot.stars}." sleep 1 if spot.city == "" location = spot.neighborhood else location = spot.city end puts "It is located at #{spot.address}, #{location}." sleep 1 if spot.telephone == "" puts "This location does not have a phone number." else puts "Their telephone is #{spot.telephone}." end puts "----------------------".colorize(:green) puts "Do you want to look at another location? [yes/no]" new_input = gets.strip.downcase if new_input == "yes" || new_input == "y" BobaFinder::Boba.reset_boba self.call elsif new_input == "no" || new_input == "n" bye else puts "Not an input. [yes/no]" end end |