Class: CoffeeBreak::CLI
- Inherits:
-
Object
- Object
- CoffeeBreak::CLI
- Defined in:
- lib/cli.rb
Instance Method Summary collapse
- #exit_program ⇒ Object
- #greeting ⇒ Object
- #loading_message ⇒ Object
- #menu ⇒ Object
-
#run ⇒ Object
Greet the user, runs CLI program.
Instance Method Details
#exit_program ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/cli.rb', line 41 def exit_program puts " " puts "Thanks for stopping by. Until next time!" puts " " exit end |
#greeting ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/cli.rb', line 32 def greeting puts "Welcome to PlayerOneCoffee! Spill the beans, what would you like?" puts "☕️" puts "Enter the number you'd like to know more about." puts "Or type exit to stop the program." puts " " end |
#loading_message ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cli.rb', line 20 def puts "Brewing coffee..." # Loading message before program starts puts "Grabbing favourite mug..." puts "Pouring into the mug..." puts " " puts "*slurps*" puts " " puts "+10 Stamina, +10 Charisma, +10 Vitality " puts " " end |
#menu ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cli.rb', line 49 def input = gets.strip.downcase if input == "i" puts " " # Blank space to show below if user makes valid. elsif input != "exit" i = Integer(input , exception: false) # Parsed input to raise exception when not false puts " " if i.between?(1,17) puts i # Prints number user entered. display_coffee(i-1) # Count starts at 0 for the computer, 1 for the user. display_again else # Raises argument if input is wrong puts " " puts "Oops! Please try again." puts " " end end input # User prompted to give input. end |
#run ⇒ Object
Greet the user, runs CLI program
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cli.rb', line 8 def run system("clear") # Clears terminal before starting CLI program Scraper.new.scrape # Displays product list from 1st page. greeting while != 'exit' # Checks to see if user will exit program. Otherwise, terminal stays open to show menu. end end |