class TodaysTopDesserts::CLI

Public Instance Methods

add_attributes_to_recipes() click to toggle source
# File lib/todays_top_desserts/cli.rb, line 19
def add_attributes_to_recipes
  #scrapes additional attributes from the individual recipe's page and adds the attributes to the Recipe
  TodaysTopDesserts::Recipe.today.each do |recipe|
    attributes = TodaysTopDesserts::Scraper.scrape_recipe(recipe.url)
    recipe.add_recipe_attributes(attributes)
  end
end
call() click to toggle source
# File lib/todays_top_desserts/cli.rb, line 3
def call
  create_recipes
  add_attributes_to_recipes
  list_desserts
  menu
  goodbye
end
create_recipes() click to toggle source
# File lib/todays_top_desserts/cli.rb, line 11
def create_recipes
  #scrapes name and url of recipes
  recipes_array = TodaysTopDesserts::Scraper.scrape_desserts

  #creates recipes using the array from the scrape_desserts method
  TodaysTopDesserts::Recipe.create_from_collection(recipes_array)
end
goodbye() click to toggle source
# File lib/todays_top_desserts/cli.rb, line 81
def goodbye
  puts ""
  puts "Hope you bake something delicious today! See you later!"
end
list_desserts() click to toggle source
# File lib/todays_top_desserts/cli.rb, line 27
def list_desserts
  puts ""
  puts "Here are today's most made desserts:"
  puts ""
  @recipes = TodaysTopDesserts::Recipe.today
  @recipes.each.with_index(1) do |recipe, i|
    puts "#{i}.".colorize(:light_black) + " #{recipe.name}"
  end

end
menu() click to toggle source
puts_recipe() click to toggle source
# File lib/todays_top_desserts/cli.rb, line 57
def puts_recipe
  puts ""
  puts "#{@the_recipe.name}".colorize(:cyan).bold
  puts "by #{@the_recipe.author}" if @the_recipe.author != ""
  puts ""
  puts "#{@the_recipe.description}".italic if @the_recipe.description != ""
  puts ""
  puts "Ready in: ".colorize(:light_black) + "#{@the_recipe.ready_time}" if @the_recipe.ready_time != ""
  puts "Prep time: ".colorize(:light_black) + "#{@the_recipe.prep_time}" if @the_recipe.prep_time != ""
  puts "Cook time: ".colorize(:light_black) + "#{@the_recipe.cook_time}" if @the_recipe.cook_time != ""
  puts "Serving size: ".colorize(:light_black) + "#{@the_recipe.serving_size}" if @the_recipe.serving_size != ""
  puts "Calorie count: ".colorize(:light_black) + "#{@the_recipe.calorie_count}" if @the_recipe.calorie_count != ""
  puts ""
  puts "INGREDIENTS:".colorize(:light_red).underline
  @the_recipe.ingredients.each do |ingredient|
    puts "#{ingredient}"
  end
  puts ""
  puts "INSTRUCTIONS:".colorize(:light_red).underline
  @the_recipe.instructions.each.with_index(1) do |instruction, i|
    puts "#{i}.".colorize(:light_black) + " #{instruction}"
  end
end