Class: TodaysTopDesserts::Recipe
- Inherits:
-
Object
- Object
- TodaysTopDesserts::Recipe
- Defined in:
- lib/todays_top_desserts/recipe.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#calorie_count ⇒ Object
Returns the value of attribute calorie_count.
-
#cook_time ⇒ Object
Returns the value of attribute cook_time.
-
#description ⇒ Object
Returns the value of attribute description.
-
#ingredients ⇒ Object
Returns the value of attribute ingredients.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#name ⇒ Object
Returns the value of attribute name.
-
#prep_time ⇒ Object
Returns the value of attribute prep_time.
-
#ready_time ⇒ Object
Returns the value of attribute ready_time.
-
#serving_size ⇒ Object
Returns the value of attribute serving_size.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_recipe_attributes(attributes_hash) ⇒ Object
-
#initialize(recipe_hash) ⇒ Recipe
constructor
A new instance of Recipe.
Constructor Details
#initialize(recipe_hash) ⇒ Recipe
Returns a new instance of Recipe.
6 7 8 9 10 |
# File 'lib/todays_top_desserts/recipe.rb', line 6 def initialize(recipe_hash) #initializes new recipe with a hash of attributes recipe_hash.each {|key, value| self.send(("#{key}="), value)} @@all << self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def @author end |
#calorie_count ⇒ Object
Returns the value of attribute calorie_count.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def calorie_count @calorie_count end |
#cook_time ⇒ Object
Returns the value of attribute cook_time.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def cook_time @cook_time end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def description @description end |
#ingredients ⇒ Object
Returns the value of attribute ingredients.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def ingredients @ingredients end |
#instructions ⇒ Object
Returns the value of attribute instructions.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def instructions @instructions end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def name @name end |
#prep_time ⇒ Object
Returns the value of attribute prep_time.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def prep_time @prep_time end |
#ready_time ⇒ Object
Returns the value of attribute ready_time.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def ready_time @ready_time end |
#serving_size ⇒ Object
Returns the value of attribute serving_size.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def serving_size @serving_size end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/todays_top_desserts/recipe.rb', line 2 def url @url end |
Class Method Details
.create_from_collection(recipes_array) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/todays_top_desserts/recipe.rb', line 12 def self.create_from_collection(recipes_array) #creates new recipes from an array of hashes that include recipe attributes recipes_array.each do |hash| TodaysTopDesserts::Recipe.new(hash) end end |
.today ⇒ Object
25 26 27 28 |
# File 'lib/todays_top_desserts/recipe.rb', line 25 def self.today #returns all instances of TodaysTopDesserts::Recipe @@all end |
Instance Method Details
#add_recipe_attributes(attributes_hash) ⇒ Object
19 20 21 22 23 |
# File 'lib/todays_top_desserts/recipe.rb', line 19 def add_recipe_attributes(attributes_hash) #adds attributes to existing recipes attributes_hash.each {|key, value| self.send(("#{key}="), value)} self end |