Class: CLI
- Inherits:
-
Object
- Object
- CLI
- Defined in:
- lib/coffee_drinks/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #doesnt_exist ⇒ Object
- #drink_details(drink) ⇒ Object
- #greeting ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #list_drinks ⇒ Object
- #list_pastries ⇒ Object
- #list_teas ⇒ Object
- #menu_details ⇒ Object
- #menu_details_second ⇒ Object
- #menu_main ⇒ Object
- #menu_milk ⇒ Object
- #menu_milk_second ⇒ Object
- #menu_no_milk ⇒ Object
- #menu_no_milk_second ⇒ Object
- #milk_drinks ⇒ Object
- #no_milk_drinks ⇒ Object
- #pastry_details(pastry) ⇒ Object
- #pastry_menu_details ⇒ Object
- #pastry_menu_details_second ⇒ Object
- #pastry_menu_details_second_tea ⇒ Object
- #pastry_menu_details_tea ⇒ Object
- #psych ⇒ Object
- #tea_details(tea) ⇒ Object
- #tea_menu ⇒ Object
- #tea_menu_details ⇒ Object
- #tea_menu_details_clone ⇒ Object
- #tea_menu_details_second ⇒ Object
- #try_again_boost ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
4 5 6 |
# File 'lib/coffee_drinks/cli.rb', line 4 def initialize Scraper.scrape_drinks end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 |
# File 'lib/coffee_drinks/cli.rb', line 9 def call greeting puts "\nType 'list' to see a list of espresso beverages.\n\n** alternatively, for the lactose challenged, type 'milk' or 'no milk' to see drinks that both will and won't give you indigestion **" puts"\n --> enter 'list', 'milk', or 'no milk' to caffeinate and 'exit' to leave <--".colorize(:color => :light_blue, :background => :white) end |
#doesnt_exist ⇒ Object
440 441 442 |
# File 'lib/coffee_drinks/cli.rb', line 440 def doesnt_exist puts "\nLooks like that drink doesn't exist yet! Try again, captain.".colorize(:light_red) end |
#drink_details(drink) ⇒ Object
409 410 411 412 413 414 415 |
# File 'lib/coffee_drinks/cli.rb', line 409 def drink_details (drink) puts "\nOrder up! One #{drink.name}:" puts "\n#{drink.description}" puts "\n#{drink.ratio}" puts "#{drink.cup}" puts "Milk: #{drink.milk}" end |
#greeting ⇒ Object
431 432 433 434 |
# File 'lib/coffee_drinks/cli.rb', line 431 def greeting puts "Hello! And welcome to the Bevvie Bevy: an interactive experience for coffee connoisseurs and novices alike.".colorize(:color => :cyan, :background => :black) puts"\nHave you ever wondered what the difference is between a flat white and long black? If so, the Bevy is here to help." end |
#list_drinks ⇒ Object
388 389 390 |
# File 'lib/coffee_drinks/cli.rb', line 388 def list_drinks Drink.all.sort_by {|drink| drink.name}.tap{|drink| drink.each.with_index(1) { |drink, i| puts "#{i}. #{drink.name}"}} end |
#list_pastries ⇒ Object
400 401 402 |
# File 'lib/coffee_drinks/cli.rb', line 400 def list_pastries Pastry.all.sort_by {|pastry| pastry.name}.tap{|pastry| pastry.each.with_index(1) { |pastry, i| puts "#{i}. #{pastry.name}"}} end |
#list_teas ⇒ Object
404 405 406 |
# File 'lib/coffee_drinks/cli.rb', line 404 def list_teas Tea.all.sort_by {|tea| tea.name}.tap{|tea| tea.each.with_index(1) { |tea, i| puts "#{i}. #{tea.name}"}} end |
#menu_details ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/coffee_drinks/cli.rb', line 42 def puts "\nTo learn more about a specific beverage enter its corresponding number below or type 'exit' to leave.".colorize(:color => :light_blue, :background => :white) input = gets.chomp.downcase if input == "exit" puts "\nAre you, perhaps, more of a tea person?".colorize(:magenta) sleep(2) elsif !input.to_i.between?(1, Drink.all.count) list_drinks doesnt_exist else drink = Drink.sorted_all[input.to_i-1] drink_details(drink) puts "\nWould you like to see another drink (y / n), view brews by milk content (milk / no milk), or could we perhaps interest you in a German pastry to go with your coffee (pastry)?".colorize(:color => :light_blue, :background => :white) end end |
#menu_details_second ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/coffee_drinks/cli.rb', line 61 def round_two = gets.chomp.downcase if round_two == "n" || round_two == "exit" puts "\nWhat about a nice cup of tea (y / n)?".colorize(:magenta) elsif round_two == "milk" milk_drinks elsif round_two == "no milk" no_milk_drinks elsif round_two == "pastry" elsif round_two == "y" list_drinks # puts "\nSelect a number to get drink details or type 'exit' to leave.".colorize(:color => :light_blue, :background => :white) else try_again_boost puts "\n--> enter 'y', 'milk', 'no milk', or 'pastry' to stay, and 'n' to leave <--".colorize(:color => :light_red, :background => :white) end end |
#menu_main ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/coffee_drinks/cli.rb', line 17 def input = gets.chomp.downcase if input == "list" list_drinks puts "\nWhat's in a name? A drink by any other name would taste as sweet." elsif input == "milk" milk_drinks puts "\nLiving a life of lactose luxury, I see." elsif input == "no milk" no_milk_drinks puts "\nFunfact: approximately 65% of the human population has a reduced ability to digest lactose after infancy. You are not alone." elsif input == "exit" puts "\nI know, I know: our latte art needs work. But wait, how about a nice strong cup of tea?".colorize(:magenta) sleep(2) else try_again_boost puts "\n--> enter 'list', 'milk', or 'no milk' to caffeinate and 'exit' to leave <--".colorize(:color => :light_red, :background => :white) end end |
#menu_milk ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/coffee_drinks/cli.rb', line 86 def puts "\nSelect a number to learn more about your favorite drink's fuel to foam ratio or enter 'exit' to leave.".colorize(:color => :light_blue, :background => :white) input = gets.chomp.downcase if input == "exit" puts "\nMaybe some tea would help?".colorize(:magenta) sleep(2) elsif !input.to_i.between?(1, Drink.milk.count) milk_drinks doesnt_exist else drink = Drink.sorted_milk[input.to_i-1] drink_details(drink) puts "\nWould you like to see another drink (y / n), visit the main or milk-free beverage lists (main / no milk), or could we perhaps tempt you with a German pastry (pastry)?".colorize(:color => :light_blue, :background => :white) end end |
#menu_milk_second ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/coffee_drinks/cli.rb', line 105 def round_two = gets.chomp.downcase if round_two == "n" || round_two == "exit" psych elsif round_two == "y" milk_drinks elsif round_two == "main" list_drinks elsif round_two == "no milk" no_milk_drinks elsif round_two == "pastry" else try_again_boost puts "\n--> enter 'y', 'main', 'no milk', or 'pastry' to stay, and 'n' to leave <--".colorize(:color => :light_red, :background => :white) end end |
#menu_no_milk ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/coffee_drinks/cli.rb', line 129 def puts "\nSelect a number to learn more about your favorite milk-free drink or type 'exit' to leave.".colorize(:color => :light_blue, :background => :white) input = gets.chomp.downcase if input == "exit" puts "These warm drinks definitely don't have milk - maybe you're more interested in tea?".colorize(:magenta) sleep(2) elsif !input.to_i.between?(1, Drink.no_milk.count) no_milk_drinks doesnt_exist else drink = Drink.sorted_no_milk[input.to_i-1] drink_details(drink) puts "\nWould you like to see another drink (y / n), visit the main or milk-containing beverage lists (main / milk), or could we get you a German pastry (pastry) to go with that coffee *lactaid not included* ?".colorize(:color => :light_blue, :background => :white) end end |
#menu_no_milk_second ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/coffee_drinks/cli.rb', line 148 def round_two = gets.chomp.downcase if round_two == "n" || round_two == "exit" psych elsif round_two == "y" no_milk_drinks elsif round_two == "main" list_drinks elsif round_two == "milk" milk_drinks elsif round_two == "pastry" else try_again_boost puts "\n--> enter 'y', 'main', 'milk', or 'pastry' to stay, and 'n' to leave <--".colorize(:color => :light_red, :background => :white) end end |
#milk_drinks ⇒ Object
392 393 394 |
# File 'lib/coffee_drinks/cli.rb', line 392 def milk_drinks Drink.milk.sort_by {|drink| drink.name}.tap{|drink| drink.each.with_index(1) { |drink, i| puts "#{i}. #{drink.name}"}} end |
#no_milk_drinks ⇒ Object
396 397 398 |
# File 'lib/coffee_drinks/cli.rb', line 396 def no_milk_drinks Drink.no_milk.sort_by {|drink| drink.name}.tap{|drink| drink.each.with_index(1) { |drink, i| puts "#{i}. #{drink.name}"}} end |
#pastry_details(pastry) ⇒ Object
424 425 426 427 |
# File 'lib/coffee_drinks/cli.rb', line 424 def pastry_details (pastry) puts "\nOrder up! One #{pastry.name}:" puts "\n#{pastry.description}" end |
#pastry_menu_details ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/coffee_drinks/cli.rb', line 288 def if Pastry.all.count > 0 list_pastries else Scraper.scrape_pastries list_pastries end puts "\nTo learn more about a pastry enter its corresponding number below.".colorize(:color => :light_blue, :background => :white) input = gets.chomp.downcase if input == "exit" puts "Not so fast, how about some tea?".colorize(:magenta) elsif !input.to_i.between?(1, Pastry.all.count) list_pastries try_again_boost else pastry = Pastry.sorted_all[input.to_i-1] pastry_details(pastry) puts "\nWould you like to see another pastry (y / n) or maybe you're ready for some tea (tea) or more coffee (coffee)?".colorize(:color => :light_blue, :background => :white) end end |
#pastry_menu_details_second ⇒ Object
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/coffee_drinks/cli.rb', line 336 def round_two = gets.chomp.downcase if round_two == "n" || round_two == "exit" puts "Sometimes we go hours without drinking coffee. It’s called sleeping.".colorize(:green) puts <<-DOC (((( (((( )))) _ .---. ( |`---'| \| | : .___, : `-----' DOC elsif round_two == "y" elsif round_two == "tea" elsif round_two == "coffee" list_drinks else try_again_boost puts "\n--> enter 'y', 'n', 'tea', or 'coffee' <--".colorize(:color => :light_red, :background => :white) end end |
#pastry_menu_details_second_tea ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/coffee_drinks/cli.rb', line 364 def round_two = gets.chomp.downcase if round_two == "get me outta here" || round_two == "exit" || round_two == "no" puts "Sometimes we go hours without drinking coffee. It’s called sleeping.".colorize(:green) puts <<-DOC (((( (((( )))) _ .---. ( |`---'| \| | : .___, : `-----' DOC elsif round_two == "y" else try_again_boost puts "\n--> enter 'y', 'n', 'tea', or 'coffee' <--".colorize(:color => :light_red, :background => :white) end end |
#pastry_menu_details_tea ⇒ Object
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/coffee_drinks/cli.rb', line 312 def if Pastry.all.count > 0 list_pastries else Scraper.scrape_pastries list_pastries end puts "\nTo learn more about a pastry enter its corresponding number below.".colorize(:color => :light_blue, :background => :white) input = gets.chomp.downcase if input == "exit" puts "Not so fast, how about some tea?".colorize(:magenta) elsif !input.to_i.between?(1, Pastry.all.count) list_pastries try_again_boost else pastry = Pastry.sorted_all[input.to_i-1] pastry_details(pastry) puts "\nWould you like to see another pastry (y) or maybe you're ready to gtfo of this program (GET ME OUTTA HERE)?".colorize(:color => :light_blue, :background => :white) end end |
#psych ⇒ Object
444 445 446 |
# File 'lib/coffee_drinks/cli.rb', line 444 def psych puts "\nHow about a cup of tea before you go (y / n)?".colorize(:magenta) end |
#tea_details(tea) ⇒ Object
417 418 419 420 421 422 |
# File 'lib/coffee_drinks/cli.rb', line 417 def tea_details (tea) puts "\nOrder up! One #{tea.name}:" puts "\n#{tea.description}" puts "\n#{tea.flavor}" puts "\n#{tea.varieties}" end |
#tea_menu ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/coffee_drinks/cli.rb', line 171 def input = gets.chomp.downcase if input == "y" elsif input == "n" || input == "exit" puts "May your coffee kick in before reality does.".colorize(:green) puts <<-DOC (((( (((( )))) _ .---. ( |`---'| \| | : .___, : `-----' DOC else try_again_boost puts "\n--> enter 'y' to stay (and learn about tea) or 'n' to leave <--".colorize(:color => :light_red, :background => :white) end end |
#tea_menu_details ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/coffee_drinks/cli.rb', line 195 def if Tea.all.count > 0 list_teas else Scraper.scrape_tea list_teas end puts "\nTo learn more about a type of tea enter its corresponding number below.".colorize(:color => :light_blue, :background => :white) puts "\n(Or if you really want to leave we promise this time we'll let you...just enter 'exit' here.)" input = gets.chomp.downcase if input == "exit" puts "No need to be sal-tea.".colorize(:green) puts <<-DOC (((( (((( )))) _ .---. ( |`---'| \| | : .___, : `-----' DOC elsif !input.to_i.between?(1, Tea.all.count) list_teas doesnt_exist else tea = Tea.sorted_all[input.to_i-1] tea_details(tea) puts "\nWould you like to see another tea (y / n) or could we perhaps interest you in a German pastry (pastry)?".colorize(:color => :light_blue, :background => :white) end end |
#tea_menu_details_clone ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/coffee_drinks/cli.rb', line 229 def if Tea.all.count > 0 list_teas else Scraper.scrape_tea list_teas end puts "\nTo learn more about a type of tea enter its corresponding number below.".colorize(:color => :light_blue, :background => :white) input = gets.chomp.downcase if input == "exit" puts "No need to be sal-tea.".colorize(:blue) puts <<-DOC (((( (((( )))) _ .---. ( |`---'| \| | : .___, : `-----' DOC elsif !input.to_i.between?(1, Tea.all.count) list_teas doesnt_exist else tea = Tea.sorted_all[input.to_i-1] tea_details(tea) puts "\nWould you like to see another tea (y / n) or could we perhaps interest you in a German pastry (pastry)?".colorize(:color => :light_blue, :background => :white) end end |
#tea_menu_details_second ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/coffee_drinks/cli.rb', line 262 def round_two = gets.chomp.downcase if round_two == "n" || round_two == "exit" puts "What do you call a sad cup of coffee? A depresso.".colorize(:green) puts <<-DOC (((( (((( )))) _ .---. ( |`---'| \| | : .___, : `-----' DOC elsif round_two == "y" elsif round_two == "pastry" else try_again_boost puts "\n--> enter 'y', 'n', or 'pastry' <--".colorize(:color => :light_red, :background => :white) end end |
#try_again_boost ⇒ Object
436 437 438 |
# File 'lib/coffee_drinks/cli.rb', line 436 def try_again_boost puts "\nLooks like you need a boost of caffeine! Give it another go, we didn't quite catch that.".colorize(:light_red) end |