Class: Alimento::PlatoEnergetico
Overview
Clase que hereda de Plato y añade funcionalidad relacionada con el impacto ambiental de un plato de alimentos.
Instance Attribute Summary
Attributes inherited from Plato
#listaAlimentos, #listaGramos, #nombre
Instance Method Summary collapse
-
#getEmisionGEI ⇒ Object
Devuelve las emisiones de gases de efecto invernadero de un plato.
-
#getTerreno ⇒ Object
Devuelve el terreno consumido por los alimentos de un plato.
-
#initialize(nombre, listaAlimentos, listaGramos) ⇒ PlatoEnergetico
constructor
A new instance of PlatoEnergetico.
- #to_s ⇒ Object
Methods inherited from Plato
#<=>, #getCarbohidratos, #getGramosTotales, #getLipidos, #getProteinas, #getValorCaloricoTotal
Constructor Details
#initialize(nombre, listaAlimentos, listaGramos) ⇒ PlatoEnergetico
Returns a new instance of PlatoEnergetico.
88 89 90 |
# File 'lib/alimento/plato.rb', line 88 def initialize (nombre, listaAlimentos, listaGramos) super(nombre, listaAlimentos, listaGramos) end |
Instance Method Details
#getEmisionGEI ⇒ Object
Devuelve las emisiones de gases de efecto invernadero de un plato.
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/alimento/plato.rb', line 92 def getEmisionGEI aux = listaAlimentos.head aux2 = listaGramos.head geiTotal = 0 while aux != nil && aux2 != nil geiTotal += aux.value.GEI * (aux2.value / 100) aux = aux.next aux2 = aux2.next end geiTotal.round(2) end |
#getTerreno ⇒ Object
Devuelve el terreno consumido por los alimentos de un plato.
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/alimento/plato.rb', line 106 def getTerreno aux = listaAlimentos.head aux2 = listaGramos.head terrenoTotal = 0 while aux != nil && aux2 != nil terrenoTotal = aux.value.terreno * (aux2.value / 100) aux = aux.next end terrenoTotal.round(2) end |
#to_s ⇒ Object
118 119 120 |
# File 'lib/alimento/plato.rb', line 118 def to_s super + "Eficiencia energética: #{getValorCaloricoTotal}\n" end |