Class: EverythingButTheKitchenSink::Recipe
- Inherits:
-
Object
- Object
- EverythingButTheKitchenSink::Recipe
- Defined in:
- lib/recipe_cli/recipe.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#time ⇒ Object
Returns the value of attribute time.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#additional_recipe_info(recipe_info) ⇒ Object
This should be handled using individual setter functions (recipe.setTime / recipe.time = #time).
-
#initialize(recipe_data) ⇒ Recipe
constructor
A new instance of Recipe.
- #save ⇒ Object
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
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/recipe_cli/recipe.rb', line 3 def id @id end |
#time ⇒ Object
Returns the value of attribute time.
3 4 5 |
# File 'lib/recipe_cli/recipe.rb', line 3 def time @time end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/recipe_cli/recipe.rb', line 3 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/recipe_cli/recipe.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
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 |
#save ⇒ Object
18 19 20 |
# File 'lib/recipe_cli/recipe.rb', line 18 def save @@all << self end |