module ButtermilkBiscuits::RecipesViews

Public Instance Methods

recipes_id_form() click to toggle source
# File lib/buttermilk_biscuits.rb, line 86
def recipes_id_form
  print "Enter recipe id: "
  gets.chomp
end
recipes_index_view(recipes) click to toggle source
# File lib/buttermilk_biscuits.rb, line 58
def recipes_index_view(recipes)
  puts "*" * 70
  recipes.each do |recipe|
    recipes_show_view(recipe)
    puts "*" * 70
  end
end
recipes_new_form() click to toggle source
# File lib/buttermilk_biscuits.rb, line 91
def recipes_new_form
  client_params = {}

  print "Title: "
  client_params[:title] = gets.chomp

  print "Ingredients: "
  client_params[:ingredients] = gets.chomp

  print "Directions: "
  client_params[:directions] = gets.chomp

  print "Prep Time: "
  client_params[:prep_time] = gets.chomp

  client_params
end
recipes_show_view(recipe) click to toggle source
# File lib/buttermilk_biscuits.rb, line 66
def recipes_show_view(recipe)
  puts 
  puts recipe.title.upcase
  puts "=" * 70
  puts "by: #{recipe.chef}".ljust(35) + "prep: #{recipe.formatted_prep_time}".rjust(35)
  puts
  puts "Ingredients"
  puts "-" * 70
  recipe.formatted_ingredients.each do |ingredient|
    puts "    • #{ingredient}"
  end
  puts
  puts "Directions"
  puts "-" * 70
  recipe.formatted_directions.each_with_index do |direction, index|
    puts "    #{index + 1}. #{direction}"
  end
  puts
end
recipes_update_form(recipe) click to toggle source
# File lib/buttermilk_biscuits.rb, line 109
def recipes_update_form(recipe)
  client_params = {}

  print "Title (#{recipe.title}): "
  client_params[:title] = gets.chomp

  print "Chef (#{recipe.chef}): "
  client_params[:chef] = gets.chomp

  print "Ingredients (#{recipe.ingredients}): "
  client_params[:ingredients] = gets.chomp

  print "Directions (#{recipe.directions}): "
  client_params[:directions] = gets.chomp

  print "Prep Time (#{recipe.prep_time}): "
  client_params[:prep_time] = gets.chomp

  client_params.delete_if { |key, value| value.empty? }
  client_params
end