Class: TodaysTopDesserts::Recipe

Inherits:
Object
  • Object
show all
Defined in:
lib/todays_top_desserts/recipe.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#authorObject

Returns the value of attribute author.



2
3
4
# File 'lib/todays_top_desserts/recipe.rb', line 2

def author
  @author
end

#calorie_countObject

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_timeObject

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

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/todays_top_desserts/recipe.rb', line 2

def description
  @description
end

#ingredientsObject

Returns the value of attribute ingredients.



2
3
4
# File 'lib/todays_top_desserts/recipe.rb', line 2

def ingredients
  @ingredients
end

#instructionsObject

Returns the value of attribute instructions.



2
3
4
# File 'lib/todays_top_desserts/recipe.rb', line 2

def instructions
  @instructions
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/todays_top_desserts/recipe.rb', line 2

def name
  @name
end

#prep_timeObject

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_timeObject

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_sizeObject

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

#urlObject

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

.todayObject



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