class Regimen
Permite calcular las emisiones y uso del terreno de un plato¶ ↑
Modo de uso¶ ↑
carne = Alimento.new(1,2,3,4,5,6) papas = Alimento.new(6,5,4,3,2,1) lista = List.new lista.insert(carne) lista.insert(papas) Plato.new("carne con papas", lista)
Public Class Methods
new(nombre,alimentos)
click to toggle source
Construye un Plato
llamando a super
Calls superclass method
Plato::new
# File lib/FoodImpact/regimen.rb, line 12 def initialize(nombre,alimentos) super(nombre,alimentos) end
Public Instance Methods
eficiencia()
click to toggle source
Devuelve la eficiencia
# File lib/FoodImpact/regimen.rb, line 39 def eficiencia kcalorias / (terreno + gei) end
gei()
click to toggle source
Devuelve la emisión de gases
# File lib/FoodImpact/regimen.rb, line 17 def gei food = @ingredientes.head gases = 0.0 while food != nil gases += food[:value].gei * (food[:value].gramos / 1000.0) food = food[:next] end gases end
huella()
click to toggle source
Devuelve la huella nutricional
# File lib/FoodImpact/regimen.rb, line 44 def huella if terreno < 800 terreno_index = 1 elsif terreno > 1200 terreno_index = 3 else terreno_index = 2 end if kcalorias < 670 energia_index = 1 elsif kcalorias > 830 energia_index = 3 else energia_index = 2 end (terreno_index + energia_index)/ 2 end
terreno()
click to toggle source
Devuelve el uso del terreno
# File lib/FoodImpact/regimen.rb, line 28 def terreno food = @ingredientes.head terreno = 0.0 while food != nil terreno += food[:value].terreno * (food[:value].gramos) food = food[:next] end terreno end