class DishImpact
Attributes
e_fp[R]
foodList[R]
grams[R]
n_fp[R]
name[R]
Public Class Methods
new(name, foods ,grams)
click to toggle source
Calls superclass method
Dish::new
# File lib/DishImpact.rb, line 15 def initialize(name, foods ,grams) super(name, foods ,grams) nutritional_footprints end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/DishImpact.rb, line 80 def <=>(other) return nil unless other.instance_of? DishImpact terrainTotal + dailygei <=> other.terrainTotal + other.dailygei end
dailygei()
click to toggle source
# File lib/DishImpact.rb, line 19 def dailygei current = @foodList.head total = 0 count = 0 while current total += (current.value.gei * @grams[count]) count += 1 current = current.next end total end
geiMean()
click to toggle source
# File lib/DishImpact.rb, line 42 def geiMean current = @foodList.head total = 0 count = 0 while current total += (current.value.gei * @grams[count]) count += 1 current = current.next end total/foodList.length end
nutritional_footprints()
click to toggle source
# File lib/DishImpact.rb, line 55 def nutritional_footprints @n_fp = 0 if energyMean < 670 then @n_fp = 1 elsif energyMean > 830 then @n_fp = 3 else @n_fp = 2 end @e_fp = 0 if dailygei < 800 then @e_fp = 1 elsif dailygei > 1200 then @e_fp = 3 else @e_fp = 2 end end
terrainTotal()
click to toggle source
# File lib/DishImpact.rb, line 30 def terrainTotal current = @foodList.head total = 0 count = 0 while current total += (current.value.terrain * @grams[count]) count += 1 current = current.next end total end
to_s()
click to toggle source
# File lib/DishImpact.rb, line 76 def to_s "(: #{@name} : gei [#{dailygei}] | terrain [#{terrainTotal}] :)" end