Class: Patient
- 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
-
#active ⇒ Object
Returns the value of attribute active.
-
#cadera ⇒ Object
Returns the value of attribute cadera.
-
#cintura ⇒ Object
Returns the value of attribute cintura.
-
#data ⇒ Object
Returns the value of attribute data.
-
#edad ⇒ Object
Returns the value of attribute edad.
-
#peso ⇒ Object
Returns the value of attribute peso.
-
#sexo ⇒ Object
Returns the value of attribute sexo.
-
#talla ⇒ Object
Returns the value of attribute talla.
Attributes inherited from Person
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Método mixin del módulo Enumerable para enumerar.
- #efecto_termogeno ⇒ Object
- #gasto_actividad_fisica ⇒ Object
- #gasto_energetico_basal ⇒ Object
- #gasto_energetico_total ⇒ Object
-
#imc ⇒ Float
Método para el cálculo de IMC.
-
#imc_table ⇒ String
Clasificación del invividuo según su IMC.
-
#initialize(name, surname, peso, talla, edad, sexo, cintura, cadera, active) ⇒ Patient
constructor
Se crea la clase Patient con sus respectivos datos.
- #peso_teorico_ideal ⇒ Object
-
#to_s ⇒ String
Se imprime por pantalla.
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
#active ⇒ Object
Returns the value of attribute active.
32 33 34 |
# File 'lib/nutritag/person.rb', line 32 def active @active end |
#cadera ⇒ Object
Returns the value of attribute cadera.
32 33 34 |
# File 'lib/nutritag/person.rb', line 32 def cadera @cadera end |
#cintura ⇒ Object
Returns the value of attribute cintura.
32 33 34 |
# File 'lib/nutritag/person.rb', line 32 def cintura @cintura end |
#data ⇒ Object
Returns the value of attribute data.
32 33 34 |
# File 'lib/nutritag/person.rb', line 32 def data @data end |
#edad ⇒ Object
Returns the value of attribute edad.
32 33 34 |
# File 'lib/nutritag/person.rb', line 32 def edad @edad end |
#peso ⇒ Object
Returns the value of attribute peso.
32 33 34 |
# File 'lib/nutritag/person.rb', line 32 def peso @peso end |
#sexo ⇒ Object
Returns the value of attribute sexo.
32 33 34 |
# File 'lib/nutritag/person.rb', line 32 def sexo @sexo end |
#talla ⇒ Object
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_termogeno ⇒ Object
112 113 114 |
# File 'lib/nutritag/person.rb', line 112 def efecto_termogeno (self.gasto_energetico_basal*0.1).round(2) end |
#gasto_actividad_fisica ⇒ Object
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_basal ⇒ Object
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_total ⇒ Object
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 |
#imc ⇒ Float
Método para el cálculo de IMC
59 60 61 |
# File 'lib/nutritag/person.rb', line 59 def imc @peso/(@talla * @talla) end |
#imc_table ⇒ String
Clasificación del invividuo según su 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_ideal ⇒ Object
96 97 98 |
# File 'lib/nutritag/person.rb', line 96 def peso_teorico_ideal (((@talla*100)-150)*0.75+50).round(2) end |
#to_s ⇒ String
Se imprime por pantalla
92 93 94 |
# File 'lib/nutritag/person.rb', line 92 def to_s puts "#{@name} #{@surname}: #{@peso}, #{@talla}, #{@edad}, #{@sexo}, #{@cintura}, #{@cadera}" end |