Class: FoodNutritionix::Food
- Inherits:
-
Object
- Object
- FoodNutritionix::Food
- Defined in:
- lib/foodnutritionix/food.rb
Instance Attribute Summary collapse
-
#consumed_at ⇒ Object
readonly
Returns the value of attribute consumed_at.
-
#food_name ⇒ Object
readonly
Returns the value of attribute food_name.
-
#nf_calories ⇒ Object
readonly
Returns the value of attribute nf_calories.
-
#nf_cholesterol ⇒ Object
readonly
Returns the value of attribute nf_cholesterol.
-
#nf_dietary_fiber ⇒ Object
readonly
Returns the value of attribute nf_dietary_fiber.
-
#nf_potassium ⇒ Object
readonly
Returns the value of attribute nf_potassium.
-
#nf_protein ⇒ Object
readonly
Returns the value of attribute nf_protein.
-
#nf_saturated_fat ⇒ Object
readonly
Returns the value of attribute nf_saturated_fat.
-
#nf_sodium ⇒ Object
readonly
Returns the value of attribute nf_sodium.
-
#nf_sugars ⇒ Object
readonly
Returns the value of attribute nf_sugars.
-
#nf_total_carbohydrate ⇒ Object
readonly
Returns the value of attribute nf_total_carbohydrate.
-
#nf_total_fat ⇒ Object
readonly
Returns the value of attribute nf_total_fat.
-
#photo ⇒ Object
readonly
Returns the value of attribute photo.
-
#serving_qty ⇒ Object
readonly
Returns the value of attribute serving_qty.
-
#serving_unit ⇒ Object
readonly
Returns the value of attribute serving_unit.
-
#serving_weight_grams ⇒ Object
readonly
Returns the value of attribute serving_weight_grams.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Food
constructor
A new instance of Food.
Constructor Details
#initialize(data) ⇒ Food
Returns a new instance of Food.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/foodnutritionix/food.rb', line 6 def initialize(data) @food_name = data['food_name'] @consumed_at = DateTime.parse(data['consumed_at']) @serving_qty = data['serving_qty'] @serving_unit = data['serving_unit'] @serving_weight_grams = data['serving_weight_grams'] @nf_calories = data['nf_calories'] @nf_total_fat = data['nf_total_fat'] @nf_saturated_fat = data['nf_saturated_fat'] @nf_cholesterol = data['nf_cholesterol'] @nf_sodium = data['nf_sodium'] @nf_total_carbohydrate = data['nf_total_carbohydrate'] @nf_dietary_fiber = data['nf_dietary_fiber'] @nf_sugars = data['nf_sugars'] @nf_protein = data['nf_protein'] @nf_potassium = data['nf_potassium'] @photo = data['photo'] end |
Instance Attribute Details
#consumed_at ⇒ Object (readonly)
Returns the value of attribute consumed_at.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def consumed_at @consumed_at end |
#food_name ⇒ Object (readonly)
Returns the value of attribute food_name.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def food_name @food_name end |
#nf_calories ⇒ Object (readonly)
Returns the value of attribute nf_calories.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_calories @nf_calories end |
#nf_cholesterol ⇒ Object (readonly)
Returns the value of attribute nf_cholesterol.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_cholesterol @nf_cholesterol end |
#nf_dietary_fiber ⇒ Object (readonly)
Returns the value of attribute nf_dietary_fiber.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_dietary_fiber @nf_dietary_fiber end |
#nf_potassium ⇒ Object (readonly)
Returns the value of attribute nf_potassium.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_potassium @nf_potassium end |
#nf_protein ⇒ Object (readonly)
Returns the value of attribute nf_protein.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_protein @nf_protein end |
#nf_saturated_fat ⇒ Object (readonly)
Returns the value of attribute nf_saturated_fat.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_saturated_fat @nf_saturated_fat end |
#nf_sodium ⇒ Object (readonly)
Returns the value of attribute nf_sodium.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_sodium @nf_sodium end |
#nf_sugars ⇒ Object (readonly)
Returns the value of attribute nf_sugars.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_sugars @nf_sugars end |
#nf_total_carbohydrate ⇒ Object (readonly)
Returns the value of attribute nf_total_carbohydrate.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_total_carbohydrate @nf_total_carbohydrate end |
#nf_total_fat ⇒ Object (readonly)
Returns the value of attribute nf_total_fat.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def nf_total_fat @nf_total_fat end |
#photo ⇒ Object (readonly)
Returns the value of attribute photo.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def photo @photo end |
#serving_qty ⇒ Object (readonly)
Returns the value of attribute serving_qty.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def serving_qty @serving_qty end |
#serving_unit ⇒ Object (readonly)
Returns the value of attribute serving_unit.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def serving_unit @serving_unit end |
#serving_weight_grams ⇒ Object (readonly)
Returns the value of attribute serving_weight_grams.
4 5 6 |
# File 'lib/foodnutritionix/food.rb', line 4 def serving_weight_grams @serving_weight_grams end |
Class Method Details
.search(*tags) ⇒ Object
25 26 27 28 |
# File 'lib/foodnutritionix/food.rb', line 25 def self.search(*) data = FoodNutrixClient.search_foods() new(data) end |