Class: FoodInfo::Adapters::FatSecret::Data::FoodServing
- Inherits:
-
Hashie::Trash
- Object
- Hashie::Trash
- FoodInfo::Adapters::FatSecret::Data::FoodServing
- Defined in:
- lib/food_info/adapters/fat_secret/data/food_serving.rb
Constant Summary collapse
- DECIMALS =
For all attributes expected, see platform.fatsecret.com/api/Default.aspx?screen=rapiref&method=food.get
%w(calories carbohydrate protein fat saturated_fat polyunsaturated_fat monounsaturated_fat trans_fat cholesterol sodium potassium fiber sugar)- INTEGERS =
%w(vitamin_a vitamin_c calcium iron)
Instance Method Summary collapse
-
#initialize(*args) ⇒ FoodServing
constructor
A new instance of FoodServing.
- #normalize_data ⇒ Object
Constructor Details
#initialize(*args) ⇒ FoodServing
Returns a new instance of FoodServing.
22 23 24 25 |
# File 'lib/food_info/adapters/fat_secret/data/food_serving.rb', line 22 def initialize(*args) super(*args) normalize_data end |
Instance Method Details
#normalize_data ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/food_info/adapters/fat_secret/data/food_serving.rb', line 27 def normalize_data self[:metric_serving_amount] = self[:metric_serving_amount].to_f self[:number_of_units] = self[:number_of_units].to_f INTEGERS.each do |n| self[n.to_sym] = self[n.to_sym].to_i end DECIMALS.each do |n| self[n.to_sym] = self[n.to_sym].to_f end end |