Class: Etiqueta_nut
- Inherits:
-
Object
- Object
- Etiqueta_nut
- Includes:
- Comparable
- Defined in:
- lib/gema/etiqueta_nut.rb
Overview
Etiqueta nutricional de un individuo
Instance Attribute Summary collapse
-
#almidon ⇒ Object
readonly
Returns the value of attribute almidon.
-
#azucares ⇒ Object
readonly
Returns the value of attribute azucares.
-
#fibra ⇒ Object
readonly
Returns the value of attribute fibra.
-
#grasas ⇒ Object
readonly
Returns the value of attribute grasas.
-
#grasas_mon ⇒ Object
readonly
Returns the value of attribute grasas_mon.
-
#grasas_pol ⇒ Object
readonly
Returns the value of attribute grasas_pol.
-
#grasas_s ⇒ Object
readonly
Returns the value of attribute grasas_s.
-
#hidratos ⇒ Object
readonly
Returns the value of attribute hidratos.
-
#kcal ⇒ Object
readonly
Returns the value of attribute kcal.
-
#kj ⇒ Object
readonly
Returns the value of attribute kj.
-
#minerales ⇒ Object
readonly
Returns the value of attribute minerales.
-
#n_porciones ⇒ Object
readonly
Returns the value of attribute n_porciones.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#polialcoholes ⇒ Object
readonly
Returns the value of attribute polialcoholes.
-
#proteinas ⇒ Object
readonly
Returns the value of attribute proteinas.
-
#sal ⇒ Object
readonly
Returns the value of attribute sal.
-
#tamaño ⇒ Object
readonly
Returns the value of attribute tamaño.
-
#vitaminas ⇒ Object
readonly
Returns the value of attribute vitaminas.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Metodo de comparaciones utilizado para el modulo comparable.
-
#initialize(nombre, grasas, grasas_s, hidratos, azucares, proteinas, sal, grasas_mon, grasas_pol, polialcoholes, almidon, fibra, vitaminas, minerales) ⇒ Etiqueta_nut
constructor
A new instance of Etiqueta_nut.
-
#porciones(n_porciones, tamaño) ⇒ Object
Añade la porciones y el tamaño a la etiqueta.
- #to_s ⇒ Object
-
#to_s_ ⇒ Object
Convierte la etiqueta a una cadena.
-
#to_s_porcentaje ⇒ Object
Convierte la etiqueta a una cadena comoun porcentaje.
-
#valor_energetico ⇒ Object
Calcula el valor energetico de una etiqueta.
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
#almidon ⇒ Object (readonly)
Returns the value of attribute almidon.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def almidon @almidon end |
#azucares ⇒ Object (readonly)
Returns the value of attribute azucares.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def azucares @azucares end |
#fibra ⇒ Object (readonly)
Returns the value of attribute fibra.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def fibra @fibra end |
#grasas ⇒ Object (readonly)
Returns the value of attribute grasas.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def grasas @grasas end |
#grasas_mon ⇒ Object (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_pol ⇒ Object (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_s ⇒ Object (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 |
#hidratos ⇒ Object (readonly)
Returns the value of attribute hidratos.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def hidratos @hidratos end |
#kcal ⇒ Object (readonly)
Returns the value of attribute kcal.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def kcal @kcal end |
#kj ⇒ Object (readonly)
Returns the value of attribute kj.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def kj @kj end |
#minerales ⇒ Object (readonly)
Returns the value of attribute minerales.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def minerales @minerales end |
#n_porciones ⇒ Object (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 |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def nombre @nombre end |
#polialcoholes ⇒ Object (readonly)
Returns the value of attribute polialcoholes.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def polialcoholes @polialcoholes end |
#proteinas ⇒ Object (readonly)
Returns the value of attribute proteinas.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def proteinas @proteinas end |
#sal ⇒ Object (readonly)
Returns the value of attribute sal.
6 7 8 |
# File 'lib/gema/etiqueta_nut.rb', line 6 def sal @sal end |
#tamaño ⇒ Object (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 |
#vitaminas ⇒ Object (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_s ⇒ Object
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_porcentaje ⇒ Object
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_energetico ⇒ Object
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 |