Class: Yummly::Recipe
- Inherits:
-
Object
- Object
- Yummly::Recipe
- Defined in:
- lib/yummly/recipe.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#attribute ⇒ Object
Nutrition attribute’s search parameter name.
- #attributes ⇒ Object
- #attribution ⇒ Object
- #description ⇒ Object
-
#flavor ⇒ Yummly::Flavor
Instance of a Yummly::Flavor object.
-
#id ⇒ String
The Yummly id for this recipe.
-
#images ⇒ Array
Collection of Yummly::Image objects.
-
#ingredient_lines ⇒ Array
Collection of strings of ingredients.
-
#ingredients ⇒ Array
Collection of strings of ingredients.
-
#initialize(recipe_json) ⇒ Recipe
constructor
A new instance of Recipe.
-
#name ⇒ String
Returns the name of the recipe, automatically finding it using the correct response node.
-
#number_of_servings ⇒ Integer
Number of servings this recipe provides.
-
#nutrition_estimates ⇒ Array
The nutritional composition of the recipe, in the form of a list of nutrients and their amounts, per serving.
- #rating ⇒ Object
- #recipe_name ⇒ Object
- #thumbnail ⇒ Object
- #total_time ⇒ Object
- #total_time_in_seconds ⇒ Object
Constructor Details
#initialize(recipe_json) ⇒ Recipe
Returns a new instance of Recipe.
12 13 14 |
# File 'lib/yummly/recipe.rb', line 12 def initialize(recipe_json) @response = recipe_json end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
10 11 12 |
# File 'lib/yummly/recipe.rb', line 10 def response @response end |
Instance Method Details
#attribute ⇒ Object
Nutrition attribute’s search parameter name.
17 18 19 |
# File 'lib/yummly/recipe.rb', line 17 def attribute response["attribute"] end |
#attributes ⇒ Object
21 22 23 |
# File 'lib/yummly/recipe.rb', line 21 def attributes response["attributes"] end |
#attribution ⇒ Object
25 26 27 |
# File 'lib/yummly/recipe.rb', line 25 def attribution @attribution ||= Yummly::Attribution.new(response["attribution"]) end |
#description ⇒ Object
29 30 31 |
# File 'lib/yummly/recipe.rb', line 29 def description response["description"] end |
#flavor ⇒ Yummly::Flavor
Returns instance of a Yummly::Flavor object.
34 35 36 |
# File 'lib/yummly/recipe.rb', line 34 def flavor @flavor ||= Yummly::Flavor.new(response["flavors"]) end |
#id ⇒ String
Returns the Yummly id for this recipe.
39 40 41 |
# File 'lib/yummly/recipe.rb', line 39 def id response["id"] end |
#images ⇒ Array
Returns collection of Yummly::Image objects.
44 45 46 |
# File 'lib/yummly/recipe.rb', line 44 def images @images ||= images_node.collect { |image| Yummly::Image.new(image) } end |
#ingredient_lines ⇒ Array
Returns collection of strings of ingredients.
54 55 56 |
# File 'lib/yummly/recipe.rb', line 54 def ingredient_lines response["ingredientLines"] end |
#ingredients ⇒ Array
Returns collection of strings of ingredients.
49 50 51 |
# File 'lib/yummly/recipe.rb', line 49 def ingredients response["ingredients"] || ingredient_lines end |
#name ⇒ String
Returns the name of the recipe, automatically finding it using the correct response node.
60 61 62 |
# File 'lib/yummly/recipe.rb', line 60 def name response["name"] || recipe_name end |
#number_of_servings ⇒ Integer
Returns number of servings this recipe provides.
65 66 67 |
# File 'lib/yummly/recipe.rb', line 65 def number_of_servings response["numberOfServings"] end |
#nutrition_estimates ⇒ Array
The nutritional composition of the recipe, in the form of a list of nutrients and their amounts, per serving. We will return nutrition estimates only for those recipes where we are reasonably confident in their accuracy. These are only estimates and you should be clear about that in what you tell your users.
73 74 75 |
# File 'lib/yummly/recipe.rb', line 73 def nutrition_estimates @nutrition_estimates ||= response["nutritionEstimates"].collect { |ne| Yummly::NutritionEstimate.new(ne) } end |
#rating ⇒ Object
77 78 79 |
# File 'lib/yummly/recipe.rb', line 77 def response["rating"] end |
#recipe_name ⇒ Object
81 82 83 |
# File 'lib/yummly/recipe.rb', line 81 def recipe_name response["recipeName"] end |
#thumbnail ⇒ Object
93 94 95 96 97 |
# File 'lib/yummly/recipe.rb', line 93 def thumbnail if images images.first.small_url end end |
#total_time ⇒ Object
85 86 87 |
# File 'lib/yummly/recipe.rb', line 85 def total_time response["totalTime"] end |
#total_time_in_seconds ⇒ Object
89 90 91 |
# File 'lib/yummly/recipe.rb', line 89 def total_time_in_seconds response["totalTimeInSeconds"] end |