class PopularRecipes::Recipe

Attributes

author[RW]

attribute accessors

directions[RW]

attribute accessors

ingredients[RW]

attribute accessors

name[RW]

attribute accessors

rating[RW]

attribute accessors

total_time[RW]

attribute accessors

url[RW]

attribute accessors

yield[RW]

attribute accessors

Public Class Methods

all() click to toggle source

return array of all instances of this class

# File lib/recipe.rb, line 39
def self.all
  @@all
end
create(array_of_hashes) click to toggle source

attribute_hash is an array of hashes that contain the attributes + values of a recipe

# File lib/recipe.rb, line 17
def self.create(array_of_hashes)
  array_of_hashes.each do |recipe|
    PopularRecipes::Recipe.new(recipe)
  end
end
new(attribute_hash) click to toggle source

<– constructors

# File lib/recipe.rb, line 9
def initialize(attribute_hash)
  attribute_hash.each do |attribute, value|
    self.send("#{attribute}=", value)
  end
  self.save
end

Public Instance Methods

add_attributes(attribute_hash) click to toggle source

add any additional attributes to an existing instance

# File lib/recipe.rb, line 27
def add_attributes(attribute_hash)
  attribute_hash.each do |attribute, value|
    self.send("#{attribute}=", value)
  end
end
save() click to toggle source

save to class variable

# File lib/recipe.rb, line 34
def save
  @@all << self
end