Class: SeattleCraftCoffee::Cli
- Inherits:
-
Object
- Object
- SeattleCraftCoffee::Cli
- Defined in:
- lib/seattle_craft_coffee/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #goodbye ⇒ Object
- #greeting ⇒ Object
- #invalid_choice ⇒ Object
- #list ⇒ Object
- #menu ⇒ Object
- #run_scraper ⇒ Object
- #sign_off ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/seattle_craft_coffee/cli.rb', line 3 def call greeting run_scraper list goodbye end |
#goodbye ⇒ Object
69 70 71 72 73 |
# File 'lib/seattle_craft_coffee/cli.rb', line 69 def goodbye puts "" puts "Goodbye..." puts "" end |
#greeting ⇒ Object
11 12 13 |
# File 'lib/seattle_craft_coffee/cli.rb', line 11 def greeting puts "Welcome to Seattle's Top Craft Coffee. Here are the top craft coffee brewers in Seattle:" end |
#invalid_choice ⇒ Object
59 60 61 62 |
# File 'lib/seattle_craft_coffee/cli.rb', line 59 def invalid_choice puts "Sorry that wasn't a valid choice" end |
#list ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/seattle_craft_coffee/cli.rb', line 19 def list SeattleCraftCoffee::Brewers.all.each.with_index(1) do |brewer, index| puts "" puts "#{index}. #{brewer.name}" puts " --Located in #{brewer.neighborhood}" end end |
#menu ⇒ Object
27 28 29 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 |
# File 'lib/seattle_craft_coffee/cli.rb', line 27 def puts "" puts "Which Craft Coffee brewer's description would you like to read? Enter the number or 'exit':" input = gets.strip if input.to_i.between?(1, 10) brewer = SeattleCraftCoffee::Brewers.all[input.to_i-1] puts "" puts "*** #{brewer.name} *** " puts "" puts " #{brewer.description} --" puts "" puts "Would you like to read about another Seattle Craft Coffee brewer?" input = gets.strip.downcase if input == "yes" || input == "y" else sign_off end elsif input == "exit" puts "" puts "Are you sure you would like to exit? Yes/No:" input = gets.strip.downcase if input == "no" || input == "n" else sign_off end else invalid_choice end end |
#run_scraper ⇒ Object
15 16 17 |
# File 'lib/seattle_craft_coffee/cli.rb', line 15 def run_scraper SeattleCraftCoffee::Scraper.scrape_brewers end |
#sign_off ⇒ Object
64 65 66 67 |
# File 'lib/seattle_craft_coffee/cli.rb', line 64 def sign_off puts "" puts "Enjoy your craft coffee! " end |