Class: Patient

Inherits:
Person show all
Includes:
Comparable
Defined in:
lib/nutritag/person.rb

Overview

Clase Patient

Clase heredada de la clase Person, que indica si un individuo es paciente de una consulta

Instance Attribute Summary collapse

Attributes inherited from Person

#name, #surname

Instance Method Summary collapse

Constructor Details

#initialize(name, surname, peso, talla, edad, sexo, cintura, cadera, active) ⇒ Patient

Se crea la clase Patient con sus respectivos datos



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/nutritag/person.rb', line 37

def initialize (name, surname, peso, talla, edad ,sexo, cintura, cadera, active)
	
	super(name,surname)
	@peso=peso
	@talla=talla
	@edad=edad
	@sexo=sexo
	@cintura=cintura
	@cadera=cadera
	@active=active
	#@data=Anthro_data.new(peso, talla, edad ,sexo, cintura, cadera)

		if (sexo == "hombre")
		@sexo = 1;
		elsif (sexo == "mujer")
		@sexo = 0;
		end
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



32
33
34
# File 'lib/nutritag/person.rb', line 32

def active
  @active
end

#caderaObject

Returns the value of attribute cadera.



32
33
34
# File 'lib/nutritag/person.rb', line 32

def cadera
  @cadera
end

#cinturaObject

Returns the value of attribute cintura.



32
33
34
# File 'lib/nutritag/person.rb', line 32

def cintura
  @cintura
end

#dataObject

Returns the value of attribute data.



32
33
34
# File 'lib/nutritag/person.rb', line 32

def data
  @data
end

#edadObject

Returns the value of attribute edad.



32
33
34
# File 'lib/nutritag/person.rb', line 32

def edad
  @edad
end

#pesoObject

Returns the value of attribute peso.



32
33
34
# File 'lib/nutritag/person.rb', line 32

def peso
  @peso
end

#sexoObject

Returns the value of attribute sexo.



32
33
34
# File 'lib/nutritag/person.rb', line 32

def sexo
  @sexo
end

#tallaObject

Returns the value of attribute talla.



32
33
34
# File 'lib/nutritag/person.rb', line 32

def talla
  @talla
end

Instance Method Details

#<=>(other) ⇒ Object

Método mixin del módulo Enumerable para enumerar



84
85
86
87
# File 'lib/nutritag/person.rb', line 84

def <=>(other)
	return nil unless other.is_a?Patient
	imc <=> other.imc
end

#efecto_termogenoObject



112
113
114
# File 'lib/nutritag/person.rb', line 112

def efecto_termogeno
		(self.gasto_energetico_basal*0.1).round(2)
end

#gasto_actividad_fisicaObject



116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/nutritag/person.rb', line 116

def gasto_actividad_fisica
	
	if active == 0 
		self.gasto_energetico_basal*0
	elsif active == 1
		(self.gasto_energetico_basal*0.12).round(2)
	elsif active == 2
		(self.gasto_energetico_basal*0.27).round(2)
	else
		(self.gasto_energetico_basal*0.54).round(2)
	end

end

#gasto_energetico_basalObject



100
101
102
103
104
105
106
107
108
109
# File 'lib/nutritag/person.rb', line 100

def gasto_energetico_basal
    	
		formula = (10*@peso)+(6.25*@talla*100)-(5*@edad)
    
		if sexo == "mujer"
        	   formula-161
    	else
        	   formula+5
    	end
end

#gasto_energetico_totalObject



130
131
132
# File 'lib/nutritag/person.rb', line 130

def gasto_energetico_total
		(self.gasto_energetico_basal + self.efecto_termogeno + self.gasto_actividad_fisica).round(2)
end

#imcFloat

Método para el cálculo de IMC

Returns:

  • (Float)

    devuelve el índice de masa corporal



59
60
61
# File 'lib/nutritag/person.rb', line 59

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

#imc_tableString

Clasificación del invividuo según su IMC

Returns:

  • (String)

    devuelve el grado del IMC



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/nutritag/person.rb', line 66

def imc_table
	r_imc =  @peso/(@talla * @talla)
	if (r_imc < 18.5)
		"Delgadez"
	elsif (r_imc > 18.5 && r_imc < 24.9)
		"Adecuado"
	elsif (r_imc > 25 && r_imc < 29.9)
		"Sobrepeso"
	elsif (r_imc > 30 && r_imc < 34.9)
		"Obesidad Grado 1"
	elsif (r_imc > 35 && r_imc < 39.9)
		"Obesidad Grado 2"
	elsif (r_imc > 40)
		"Obesidad Grado 3"
	end
end

#peso_teorico_idealObject



96
97
98
# File 'lib/nutritag/person.rb', line 96

def peso_teorico_ideal
   	(((@talla*100)-150)*0.75+50).round(2)
end

#to_sString

Se imprime por pantalla

Returns:

  • (String)

    datos del paciente formateados



92
93
94
# File 'lib/nutritag/person.rb', line 92

def to_s
	puts "#{@name} #{@surname}: #{@peso}, #{@talla}, #{@edad}, #{@sexo}, #{@cintura}, #{@cadera}"
end