Class: Regimen
Overview
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)
Instance Attribute Summary
Attributes inherited from Plato
Instance Method Summary collapse
-
#eficiencia ⇒ Object
Devuelve la eficiencia.
-
#gei ⇒ Object
Devuelve la emisión de gases.
-
#huella ⇒ Object
Devuelve la huella nutricional.
-
#initialize(nombre, alimentos) ⇒ Regimen
constructor
Construye un Plato llamando a super.
-
#terreno ⇒ Object
Devuelve el uso del terreno.
Methods inherited from Plato
#<=>, #carbohidratos, #kcalorias, #lipidos, #proteinas, #to_s
Constructor Details
#initialize(nombre, alimentos) ⇒ Regimen
Construye un Plato llamando a super
12 13 14 |
# File 'lib/FoodImpact/regimen.rb', line 12 def initialize(nombre,alimentos) super(nombre,alimentos) end |
Instance Method Details
#eficiencia ⇒ Object
Devuelve la eficiencia
39 40 41 |
# File 'lib/FoodImpact/regimen.rb', line 39 def eficiencia kcalorias / (terreno + gei) end |
#gei ⇒ Object
Devuelve la emisión de gases
17 18 19 20 21 22 23 24 25 |
# 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 ⇒ Object
Devuelve la huella nutricional
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# 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 ⇒ Object
Devuelve el uso del terreno
28 29 30 31 32 33 34 35 36 |
# 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 |