Class: EverythingButTheKitchenSink::Recipe

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recipe_data) ⇒ Recipe



6
7
8
9
10
11
# File 'lib/recipe_cli/recipe.rb', line 6

def initialize(recipe_data)
  recipe_data.each {|key, value| self.send(("#{key}="), value)}
  @id = recipe_data[:id]
  @title = recipe_data[:title]
  save
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/recipe_cli/recipe.rb', line 3

def id
  @id
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/recipe_cli/recipe.rb', line 3

def time
  @time
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/recipe_cli/recipe.rb', line 3

def title
  @title
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/recipe_cli/recipe.rb', line 3

def url
  @url
end

Class Method Details

.allObject



22
23
24
# File 'lib/recipe_cli/recipe.rb', line 22

def self.all
  @@all
end

Instance Method Details

#additional_recipe_info(recipe_info) ⇒ Object

This should be handled using individual setter functions (recipe.setTime / recipe.time = #time)



13
14
15
16
# File 'lib/recipe_cli/recipe.rb', line 13

def additional_recipe_info(recipe_info) # This should be handled using individual setter functions (recipe.setTime / recipe.time = {time})
  @time = recipe_info[:readyInMinutes]
  @url = recipe_info[:sourceUrl]
end

#saveObject



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

def save
  @@all << self
end