class CLI

Public Class Methods

new() click to toggle source
# File lib/coffee_drinks/cli.rb, line 4
def initialize
    Scraper.scrape_drinks
end

Public Instance Methods

call() click to toggle source
# 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)
    menu_main
end
doesnt_exist() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
menu_details_second() click to toggle source
menu_main() click to toggle source
menu_milk() click to toggle source
menu_milk_second() click to toggle source
menu_no_milk() click to toggle source
menu_no_milk_second() click to toggle source
milk_drinks() click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/coffee_drinks/cli.rb, line 288
def pastry_menu_details
    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)
        tea_menu_details
    elsif !input.to_i.between?(1, Pastry.all.count)
        list_pastries
        try_again_boost
        pastry_menu_details
    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)
        pastry_menu_details_second
    end
end
pastry_menu_details_second() click to toggle source
# File lib/coffee_drinks/cli.rb, line 336
  def pastry_menu_details_second
      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"
          pastry_menu_details
      elsif round_two == "tea"
          tea_menu_details_clone
      elsif round_two == "coffee"
          list_drinks
          menu_details
      else 
          try_again_boost
          puts "\n--> enter 'y', 'n', 'tea', or 'coffee' <--".colorize(:color => :light_red, :background => :white)
          pastry_menu_details_second
      end
  end
pastry_menu_details_second_tea() click to toggle source
# File lib/coffee_drinks/cli.rb, line 364
  def pastry_menu_details_second_tea
      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"
          pastry_menu_details
      else 
          try_again_boost
          puts "\n--> enter 'y', 'n', 'tea', or 'coffee' <--".colorize(:color => :light_red, :background => :white)
          pastry_menu_details_second_tea
      end
  end
pastry_menu_details_tea() click to toggle source
# File lib/coffee_drinks/cli.rb, line 312
def pastry_menu_details_tea
    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)
        tea_menu_details
    elsif !input.to_i.between?(1, Pastry.all.count)
        list_pastries
        try_again_boost
        pastry_menu_details
    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)
        pastry_menu_details_second_tea
    end
end
psych() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/coffee_drinks/cli.rb, line 171
  def tea_menu
      input = gets.chomp.downcase
      if input == "y"
          tea_menu_details
      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)
          tea_menu
      end
  end
tea_menu_details() click to toggle source
# File lib/coffee_drinks/cli.rb, line 195
  def tea_menu_details
      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
          tea_menu_details_clone
      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)
          tea_menu_details_second
      end
  end
tea_menu_details_clone() click to toggle source
# File lib/coffee_drinks/cli.rb, line 229
  def tea_menu_details_clone
      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
          tea_menu_details_clone
      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)
          tea_menu_details_second
      end
  end
tea_menu_details_second() click to toggle source
# File lib/coffee_drinks/cli.rb, line 262
  def tea_menu_details_second
      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"
          tea_menu_details_clone
      elsif round_two == "pastry"
          pastry_menu_details_tea
      else 
          try_again_boost
          puts "\n--> enter 'y', 'n', or 'pastry' <--".colorize(:color => :light_red, :background => :white)
          tea_menu_details_second
      end
  end
try_again_boost() click to toggle source
# 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