Class: Etiqueta

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nombre, grasa, saturadas, hidratos, proteinas, azucares, sal, porcion, monoinsaturadas, poliinsaturadas, fibra_alimentaria, polialcoholes, almidon, vit_min) ⇒ Etiqueta

Returns a new instance of Etiqueta.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gema/etiqueta_nutricional.rb', line 4

def initialize(nombre,grasa,saturadas, hidratos, proteinas,azucares, sal,porcion, monoinsaturadas,poliinsaturadas,fibra_alimentaria,polialcoholes,almidon,vit_min)
	@nombre=nombre
	@grasa=grasa
	@saturadas=saturadas
	@hidratos=hidratos
	@proteinas=proteinas
	@azucares=azucares
	@sal=sal
	@fibra_alimentaria=fibra_alimentaria
	@monoinsaturadas=monoinsaturadas
	@poliinsaturadas=poliinsaturadas
	@polialcoholes=polialcoholes
	@almidon=almidon
	@vit_min=vit_min
	@valor_energetico=[v_energeticokJ,v_energeticokc]
	@porcion=porcion/100
	@valor_porcion=[porcion_kJ,porcion_kc]
	@IR=[8400,2000,70,20,260,50,90,6]
end

Instance Attribute Details

#almidonObject (readonly)

Returns the value of attribute almidon.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def almidon
  @almidon
end

#azucaresObject (readonly)

Returns the value of attribute azucares.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def azucares
  @azucares
end

#fibra_alimentariaObject (readonly)

Returns the value of attribute fibra_alimentaria.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def fibra_alimentaria
  @fibra_alimentaria
end

#grasaObject (readonly)

Returns the value of attribute grasa.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def grasa
  @grasa
end

#hidratosObject (readonly)

Returns the value of attribute hidratos.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def hidratos
  @hidratos
end

#monoinsaturadasObject (readonly)

Returns the value of attribute monoinsaturadas.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def monoinsaturadas
  @monoinsaturadas
end

#nombreObject (readonly)

Returns the value of attribute nombre.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def nombre
  @nombre
end

#polialcoholesObject (readonly)

Returns the value of attribute polialcoholes.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def polialcoholes
  @polialcoholes
end

#poliinsaturadasObject (readonly)

Returns the value of attribute poliinsaturadas.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def poliinsaturadas
  @poliinsaturadas
end

#porcionObject (readonly)

Returns the value of attribute porcion.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def porcion
  @porcion
end

#proteinasObject (readonly)

Returns the value of attribute proteinas.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def proteinas
  @proteinas
end

#salObject (readonly)

Returns the value of attribute sal.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def sal
  @sal
end

#saturadasObject (readonly)

Returns the value of attribute saturadas.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def saturadas
  @saturadas
end

#valor_energeticoObject (readonly)

Returns the value of attribute valor_energetico.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def valor_energetico
  @valor_energetico
end

#valor_porcionObject (readonly)

Returns the value of attribute valor_porcion.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def valor_porcion
  @valor_porcion
end

#vit_minObject (readonly)

Returns the value of attribute vit_min.



3
4
5
# File 'lib/gema/etiqueta_nutricional.rb', line 3

def vit_min
  @vit_min
end

Instance Method Details

#<=>(other) ⇒ Object



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

def <=>(other)
		return nil unless other.instance_of?Etiqueta
   		@proteinas <=> other.proteinas
end

#gt_6?Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
# File 'lib/gema/etiqueta_nutricional.rb', line 35

def gt_6?
	if (@sal >= 6)
	     true
	else
   		false
	end
end

#porcion_kcObject



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

def porcion_kc
	v_energeticokc*@porcion
end

#porcion_kJObject



29
30
31
# File 'lib/gema/etiqueta_nutricional.rb', line 29

def porcion_kJ
	v_energeticokJ*@porcion
end

#to_sObject



46
47
48
# File 'lib/gema/etiqueta_nutricional.rb', line 46

def to_s
	"#{@proteinas}"
end

#v_energeticokcObject



26
27
28
# File 'lib/gema/etiqueta_nutricional.rb', line 26

def v_energeticokc
	(9.0*@grasa)+(4.0*@hidratos)+(4.0*@proteinas)+(6*@sal)
end

#v_energeticokJObject



23
24
25
# File 'lib/gema/etiqueta_nutricional.rb', line 23

def v_energeticokJ
	(37.0*@grasa)+(17.0*@hidratos)+(17.0*@proteinas)+(25*@sal)
end