Class: ActiveNutrition::Objects::Food

Inherits:
Base
  • Object
show all
Defined in:
lib/active_nutrition/objects/food.rb

Constant Summary collapse

METHOD_MAP =
{ :name => :Long_Desc,
:ndb_number => :NDB_No,
:common_name => :ComName,
:manufacturers_name => :ManufacName,
:survey => :Survey,
:scientific_name => :SciName,
:fat_factor => :Fat_Factor,
:protein_factor => :Pro_Factor }

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #base_model

Instance Method Summary collapse

Methods inherited from Base

#initialize, wrap

Constructor Details

This class inherits a constructor from ActiveNutrition::Objects::Base

Instance Attribute Details

#food_groupObject (readonly)

Returns the value of attribute food_group.



19
20
21
# File 'lib/active_nutrition/objects/food.rb', line 19

def food_group
  @food_group
end

#nutrition_factsObject (readonly)

Returns the value of attribute nutrition_facts.



19
20
21
# File 'lib/active_nutrition/objects/food.rb', line 19

def nutrition_facts
  @nutrition_facts
end

Instance Method Details

#factorsObject



33
34
35
36
37
38
# File 'lib/active_nutrition/objects/food.rb', line 33

def factors
  [:fat_factor, :protein_factor].inject({}) do |ret, factor|
    ret[factor] = attributes[METHOD_MAP[factor].to_s]
    ret
  end
end

#weightsObject



29
30
31
# File 'lib/active_nutrition/objects/food.rb', line 29

def weights
  @weights ||= Weights.new(Weight.wrap(base_model.weights))
end