Class: Etiqueta_nut

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/gema/etiqueta_nut.rb

Overview

Etiqueta nutricional de un individuo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nombre, grasas, grasas_s, hidratos, azucares, proteinas, sal, grasas_mon, grasas_pol, polialcoholes, almidon, fibra, vitaminas, minerales) ⇒ Etiqueta_nut

Returns a new instance of Etiqueta_nut.



9
10
11
# File 'lib/gema/etiqueta_nut.rb', line 9

def initialize(nombre,grasas,grasas_s,hidratos,azucares,proteinas,sal,grasas_mon,grasas_pol,polialcoholes,almidon,fibra,vitaminas,minerales)
	@nombre,@grasas,@grasas_s,@hidratos,@azucares,@proteinas,@sal,@grasas_mon,@grasas_pol,@polialcoholes,@almidon,@fibra,@vitaminas,@minerales = nombre,grasas,grasas_s,hidratos,azucares,proteinas,sal,grasas_mon,grasas_pol,polialcoholes,almidon,fibra,vitaminas,minerales
end

Instance Attribute Details

#almidonObject (readonly)

Returns the value of attribute almidon.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def almidon
  @almidon
end

#azucaresObject (readonly)

Returns the value of attribute azucares.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def azucares
  @azucares
end

#fibraObject (readonly)

Returns the value of attribute fibra.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def fibra
  @fibra
end

#grasasObject (readonly)

Returns the value of attribute grasas.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def grasas
  @grasas
end

#grasas_monObject (readonly)

Returns the value of attribute grasas_mon.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def grasas_mon
  @grasas_mon
end

#grasas_polObject (readonly)

Returns the value of attribute grasas_pol.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def grasas_pol
  @grasas_pol
end

#grasas_sObject (readonly)

Returns the value of attribute grasas_s.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def grasas_s
  @grasas_s
end

#hidratosObject (readonly)

Returns the value of attribute hidratos.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def hidratos
  @hidratos
end

#kcalObject (readonly)

Returns the value of attribute kcal.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def kcal
  @kcal
end

#kjObject (readonly)

Returns the value of attribute kj.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def kj
  @kj
end

#mineralesObject (readonly)

Returns the value of attribute minerales.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def minerales
  @minerales
end

#n_porcionesObject (readonly)

Returns the value of attribute n_porciones.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def n_porciones
  @n_porciones
end

#nombreObject (readonly)

Returns the value of attribute nombre.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def nombre
  @nombre
end

#polialcoholesObject (readonly)

Returns the value of attribute polialcoholes.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def polialcoholes
  @polialcoholes
end

#proteinasObject (readonly)

Returns the value of attribute proteinas.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def proteinas
  @proteinas
end

#salObject (readonly)

Returns the value of attribute sal.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def sal
  @sal
end

#tamañoObject (readonly)

Returns the value of attribute tamaño.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def tamaño
  @tamaño
end

#vitaminasObject (readonly)

Returns the value of attribute vitaminas.



6
7
8
# File 'lib/gema/etiqueta_nut.rb', line 6

def vitaminas
  @vitaminas
end

Instance Method Details

#<=>(other) ⇒ Object

Metodo de comparaciones utilizado para el modulo comparable



42
43
44
# File 'lib/gema/etiqueta_nut.rb', line 42

def <=> (other)
	self.nombre <=> other.nombre
end

#porciones(n_porciones, tamaño) ⇒ Object

Añade la porciones y el tamaño a la etiqueta



14
15
16
# File 'lib/gema/etiqueta_nut.rb', line 14

def porciones(n_porciones,tamaño)
	@n_porciones,@tamaño = n_porciones,tamaño
end

#to_sObject



25
26
27
28
29
# File 'lib/gema/etiqueta_nut.rb', line 25

def to_s()

"#{@nombre}".ljust(24) + "#{@grasas}\t#{@hidratos}\t\t#{@azucares}\t\t#{@proteinas}\t\t#{@sal}\t#{@polialcoholes}\t\t#{@almidon}\t#{@fibra}\t#{@vitaminas}\t\t#{@minerales}\t\t#{@kcal}"

end

#to_s_Object

Convierte la etiqueta a una cadena



32
33
34
# File 'lib/gema/etiqueta_nut.rb', line 32

def to_s_()
"Nombre:#{@nombre}\nGrasas:#{@grasas}\nGrasas Saturadas:#{@grasas_s}\nHidratos:#{@hidratos}\nAzúcares:#{@azucares}\nNombre:#{@proteinas}\nSal:#{@sal}\nGrasas Monoinsaturasas:#{@grasas_mon}\nGrasas Polisaturadas:#{@grasas_pol}\nPolialcoholes:#{@polialcoholes}\nAlmidon:#{@almidon}\nFibra:#{@fibra}\nVitaminas:#{@vitaminas}\nMinerales:#{@minerales}\nEnergía (Kj):#{@kj}\nEnergía (Kcal):#{@kcal}\n"	
end

#to_s_porcentajeObject

Convierte la etiqueta a una cadena comoun porcentaje



37
38
39
# File 'lib/gema/etiqueta_nut.rb', line 37

def to_s_porcentaje()
"Nombre:#{@nombre}\nGrasas:#{@grasas/100.0}\nGrasas Saturadas:#{@grasas_s/100.0}\nHidratos:#{@hidratos/100.0}\nAzúcares:#{@azucares/100.0}\nNombre:#{@proteinas/100.0}\nSal:#{@sal/100.0}\nGrasas Monoinsaturasas:#{@grasas_mon/100.0}\nGrasas Polisaturadas:#{@grasas_pol/100.0}\nPolialcoholes:#{@polialcoholes/100.0}\nAlmidon:#{@almidon/100.0}\nFibra:#{@fibra/100.0}\nVitaminas:#{@vitaminas/100.0}\nMinerales:#{@minerales/100.0}\nEnergía (Kj):#{@kj/100.0}\nEnergía (Kcal):#{@kcal/100.0}\nVALORES DE REFERENCIA:\nValor energético:8.400kJ/ 2000kcal/g\nGrasa total: 70g\nAcidos grasos saturados: 20g\nHidratos de carbono: 260g\nAzúcares: 90g\nProteínas: 50g\nSal: 6g\n"	
end

#valor_energeticoObject

Calcula el valor energetico de una etiqueta



19
20
21
22
23
# File 'lib/gema/etiqueta_nut.rb', line 19

def valor_energetico()
	@kj = @grasas*37 + @grasas_s*37 + @hidratos*17 + @azucares*81 + @proteinas*50 + @sal*25 + @grasas_mon*37 + @grasas_pol*37 +  @polialcoholes*10 + @almidon*17 + @fibra * 8 + @minerales*5
	@kcal = @grasas*9 + @grasas_s*9 + @hidratos*4 + @azucares*19 + @proteinas*4 + @sal*6 + @grasas_mon*9 + @grasas_pol*9 +  @polialcoholes*2.4 + @almidon*4 + @fibra*2 + @minerales*2

end