class Alimento
@author Juan Martínez
Attributes
carbohidratos[R]
gei[R]
lipidos[R]
nombre[R]
proteinas[R]
terreno[R]
Public Class Methods
new(nombre, proteinas, carbohidratos, lipidos, gei, terreno)
click to toggle source
# File lib/tdd.rb, line 8 def initialize (nombre, proteinas, carbohidratos, lipidos, gei, terreno) @nombre = nombre @proteinas = proteinas @carbohidratos = carbohidratos @lipidos = lipidos @gei = gei @terreno = terreno end
Public Instance Methods
<=>(another)
click to toggle source
# File lib/tdd.rb, line 59 def <=> (another) self.valor_energetico <=> another.valor_energetico end
get_gei()
click to toggle source
# File lib/tdd.rb, line 21 def get_gei "GEI: #{@gei} kgCO2eq" end
get_nombre()
click to toggle source
# File lib/tdd.rb, line 17 def get_nombre "Nombre: #{@nombre}" end
get_terreno()
click to toggle source
# File lib/tdd.rb, line 25 def get_terreno "Terreno: #{@terreno} m2/año" end
huella_nutricional()
click to toggle source
# File lib/tdd.rb, line 49 def huella_nutricional if self.valor_energetico < 670 and self.gei < 800 return 1,self elseif self.valor_energetico.between?(670,830) and self.gei.between?(800-1200) return 2,self else return 3,self end end
impacto_ambiental()
click to toggle source
# File lib/tdd.rb, line 45 def impacto_ambiental true end
to_s()
click to toggle source
Formatea el alimento
@return [String]
# File lib/tdd.rb, line 32 def to_s "Nombre: #{@nombre}\n " + "Proteinas: #{@proteinas}\n " + "Carbohidratos: #{@carbohidratos}\n " + "Lipidos: #{@lipidos}\n " + "GEI: #{@gei}\n " + "Terreno: #{@terreno}" end
valor_energetico()
click to toggle source
# File lib/tdd.rb, line 41 def valor_energetico (@lipidos * 9) + (@proteinas * 4) + (@carbohidratos * 4) end