Class: RecipeCard

Inherits:
Object
  • Object
show all
Includes:
RecipeHelper
Defined in:
lib/recipe_card.rb

Constant Summary

Constants included from RecipeHelper

RecipeHelper::HEADERS, RecipeHelper::PROMPT, RecipeHelper::RECIPES_PATH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, serves, description, ingredients, recipe, time_to_cook, url) ⇒ RecipeCard

Returns a new instance of RecipeCard.



6
7
8
9
10
11
12
13
14
# File 'lib/recipe_card.rb', line 6

def initialize(name, serves, description, ingredients, recipe, time_to_cook, url)
  @name = name
  @serves = serves
  @description = description
  @ingredients = ingredients
  @recipe = recipe
  @time_to_cook = time_to_cook
  @url = url
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/recipe_card.rb', line 5

def description
  @description
end

#ingredientsObject (readonly)

Returns the value of attribute ingredients.



5
6
7
# File 'lib/recipe_card.rb', line 5

def ingredients
  @ingredients
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/recipe_card.rb', line 5

def name
  @name
end

#recipeObject (readonly)

Returns the value of attribute recipe.



5
6
7
# File 'lib/recipe_card.rb', line 5

def recipe
  @recipe
end

#servesObject (readonly)

Returns the value of attribute serves.



5
6
7
# File 'lib/recipe_card.rb', line 5

def serves
  @serves
end

#time_to_cookObject (readonly)

Returns the value of attribute time_to_cook.



5
6
7
# File 'lib/recipe_card.rb', line 5

def time_to_cook
  @time_to_cook
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/recipe_card.rb', line 5

def url
  @url
end

Class Method Details

.user_recipeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/recipe_card.rb', line 21

def self.user_recipe
  recipe = {}
  HEADERS.each do |input|
    puts "Type out your ingredients separated with commas eg. banana, shrimp, taco meat" if input == :ingredients
    puts "You  need to enter a url it might be nice for inspiration?" if input == :url
    puts "Whats the #{input}?"
    print '> '
    
    recipe[input] = gets.chomp
  end
  
  recipe
end

Instance Method Details

#split_ingredients(ingredients) ⇒ Object



15
16
17
# File 'lib/recipe_card.rb', line 15

def split_ingredients(ingredients)
ingredients.split(' ')
end

#to_aObject



18
19
20
# File 'lib/recipe_card.rb', line 18

def to_a
  [@name, @serves, @description, @ingredients, @recipe, @time_to_cook, @url]
end