Class: ActiveNutrition::Objects::NutritionFacts

Inherits:
Array
  • Object
show all
Defined in:
lib/active_nutrition/objects/nutrition_facts.rb

Instance Method Summary collapse

Instance Method Details

#to_hash(options = {}) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/active_nutrition/objects/nutrition_facts.rb', line 6

def to_hash(options = {})
  options[:by] ||= :description
  inject({}) do |ret, fact|
    ret[fact.send(options[:by])] = fact.value
    ret
  end
end