Class: Valores_nut

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

Overview

Valoracion nutricional de un individuo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nombre, edad, genero) ⇒ Valores_nut

Returns a new instance of Valores_nut.



10
11
12
# File 'lib/gema/valores_nut.rb', line 10

def initialize(nombre,edad,genero)
	@nombre, @edad, @genero = nombre, edad, genero
end

Instance Attribute Details

#edadObject (readonly)

Returns the value of attribute edad.



7
8
9
# File 'lib/gema/valores_nut.rb', line 7

def edad
  @edad
end

#generoObject (readonly)

Returns the value of attribute genero.



7
8
9
# File 'lib/gema/valores_nut.rb', line 7

def genero
  @genero
end

#nombreObject (readonly)

Returns the value of attribute nombre.



7
8
9
# File 'lib/gema/valores_nut.rb', line 7

def nombre
  @nombre
end

Instance Method Details

#<=>(other) ⇒ Object

Metodo utilizado para comparaciones de valoraciones nutricionales



35
36
37
# File 'lib/gema/valores_nut.rb', line 35

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

#grasa(sexo, peso, talla) ⇒ Object

Calcula la grasa de un individuo



20
21
22
# File 'lib/gema/valores_nut.rb', line 20

def grasa(sexo,peso,talla)
	@grasa = 1.2*imc(peso,talla)+0.23*@edad-10.8*sexo-5.4
end

#imc(peso, talla) ⇒ Object

Calcula el Imc de un individuo



15
16
17
# File 'lib/gema/valores_nut.rb', line 15

def imc(peso,talla)
	@imc =  (peso/(talla*talla))
end

#rcc(c_cintura, c_cadera) ⇒ Object

Calcula el rcc de un individuo



25
26
27
# File 'lib/gema/valores_nut.rb', line 25

def rcc(c_cintura,c_cadera)
	@rcc = (c_cintura/c_cadera)	
end

#to_sObject

Convierte la valoracion nutricional a una cadena



30
31
32
# File 'lib/gema/valores_nut.rb', line 30

def to_s
	"Nombre:#{@nombre}\nEdad:#{@edad}\nGenero:#{@genero}\nImc:#{@imc}\n%Grasa:#{@grasa}\nRcc:#{@rcc}"
end