Class: Paciente
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/alu0100406580_nutricion/paciente.rb
Instance Attribute Summary collapse
-
#edad ⇒ Object
readonly
Returns the value of attribute edad.
-
#factorActividad ⇒ Object
readonly
Returns the value of attribute factorActividad.
-
#fecha ⇒ Object
readonly
Returns the value of attribute fecha.
-
#genero ⇒ Object
Returns the value of attribute genero.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#pc_bicipital ⇒ Object
Returns the value of attribute pc_bicipital.
-
#pc_subescapular ⇒ Object
Returns the value of attribute pc_subescapular.
-
#pc_suprailiaco ⇒ Object
Returns the value of attribute pc_suprailiaco.
-
#pc_tricipital ⇒ Object
Returns the value of attribute pc_tricipital.
-
#peso ⇒ Object
Returns the value of attribute peso.
-
#talla ⇒ Object
readonly
Returns the value of attribute talla.
Attributes inherited from Persona
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #bicipital ⇒ Object
- #each ⇒ Object
- #gastoEnergiaTotal ⇒ Object
- #imc ⇒ Object
-
#initialize(nombre, apellidos, edad, genero, peso, talla, factorActividad = 0) ⇒ Paciente
constructor
A new instance of Paciente.
- #pliegues(pc_bicipital, pc_tricipital, pc_subescapular, pc_suprailiaco) ⇒ Object
- #porcent_grasa ⇒ Object
- #rcc(cintura, cadera) ⇒ Object
- #subescapular ⇒ Object
- #suprailiaco ⇒ Object
- #to_s ⇒ Object
- #tricipital ⇒ Object
Constructor Details
#initialize(nombre, apellidos, edad, genero, peso, talla, factorActividad = 0) ⇒ Paciente
Returns a new instance of Paciente.
53 54 55 56 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 53 def initialize(nombre,apellidos,edad, genero, peso, talla, factorActividad = 0) super(@nombre = nombre, @apellidos = apellidos, @edad = edad, @genero = genero) @peso, @talla, @factorActividad = peso, talla, factorActividad end |
Instance Attribute Details
#edad ⇒ Object (readonly)
Returns the value of attribute edad.
50 51 52 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 50 def edad @edad end |
#factorActividad ⇒ Object (readonly)
Returns the value of attribute factorActividad.
50 51 52 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 50 def factorActividad @factorActividad end |
#fecha ⇒ Object (readonly)
Returns the value of attribute fecha.
50 51 52 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 50 def fecha @fecha end |
#genero ⇒ Object
Returns the value of attribute genero.
51 52 53 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 51 def genero @genero end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
50 51 52 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 50 def nombre @nombre end |
#pc_bicipital ⇒ Object
Returns the value of attribute pc_bicipital.
51 52 53 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 51 def pc_bicipital @pc_bicipital end |
#pc_subescapular ⇒ Object
Returns the value of attribute pc_subescapular.
51 52 53 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 51 def pc_subescapular @pc_subescapular end |
#pc_suprailiaco ⇒ Object
Returns the value of attribute pc_suprailiaco.
51 52 53 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 51 def pc_suprailiaco @pc_suprailiaco end |
#pc_tricipital ⇒ Object
Returns the value of attribute pc_tricipital.
51 52 53 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 51 def pc_tricipital @pc_tricipital end |
#peso ⇒ Object
Returns the value of attribute peso.
51 52 53 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 51 def peso @peso end |
#talla ⇒ Object (readonly)
Returns the value of attribute talla.
50 51 52 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 50 def talla @talla end |
Instance Method Details
#<=>(other) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 146 def <=>(other) return nil unless other.instance_of? Paciente mayor = 0 menor = 0 mayor += 1 if self.peso > other.peso mayor += 1 if self.talla > other.talla mayor += 1 if self.imc > other.imc mayor += 1 if self.porcent_grasa > other.porcent_grasa menor += 1 if self.peso < other.peso menor += 1 if self.talla < other.talla menor += 1 if self.imc < other.imc menor += 1 if self.porcent_grasa < other.porcent_grasa return mayor <=> menor if ((mayor && menor) != 0) return 0<=>0 end |
#bicipital ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 89 def bicipital() bicipi = [] for i in 1..3 puts "Introduzca medida #{i} para pliegue Bicipital:" j = gets.to_i bicipi.push(j) end sum = bicipi.inject(0){ |sum, x| sum + x } @pc_bicipital = (sum/bicipi.size.to_f).round(2) return "El pliegue Bicipital medio es -> #{pc_bicipital}mm" end |
#each ⇒ Object
167 168 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 167 def each end |
#gastoEnergiaTotal ⇒ Object
137 138 139 140 141 142 143 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 137 def gastoEnergiaTotal() #pesoTeorico = (@talla - 150) * 0.75 + 50 gastoEnerBasal = @genero == 1 ? (@peso * 10) + (6.25 * @talla) - (5 * @edad) + 5 : (@peso * 10) + (6.25 * @talla) - (5 * @edad) - 161 efectoTermogeno = (gastoEnerBasal * 0.10).round(2) gastoActividadFisica = gastoEnerBasal * factorActividad (gastoEnerBasal + efectoTermogeno + gastoActividadFisica).round(2) end |
#imc ⇒ Object
66 67 68 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 66 def imc return (@peso/(@talla*@talla)).round(2) end |
#pliegues(pc_bicipital, pc_tricipital, pc_subescapular, pc_suprailiaco) ⇒ Object
58 59 60 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 58 def pliegues(pc_bicipital,pc_tricipital,pc_subescapular,pc_suprailiaco) @pc_bicipital,@pc_tricipital,@pc_subescapular,@pc_suprailiaco = pc_bicipital,pc_tricipital,pc_subescapular,pc_suprailiaco end |
#porcent_grasa ⇒ Object
85 86 87 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 85 def porcent_grasa return (1.2*self.imc+0.23*@edad-10.8*@genero-5.4).round(3) end |
#rcc(cintura, cadera) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 70 def rcc(cintura,cadera) rcc = (cintura/cadera) if ((@genero == 1 && rcc >= 0.83 && rcc <= 0.88) || (@genero == 0 && rcc >= 0.72 && rcc <= 0.75)) return "Riesgo Bajo RCC: #{rcc.round(2)}" elsif ((@genero == 1 && rcc >= 0.88 && rcc <= 0.95) || (@genero == 0 && rcc >= 0.78 && rcc <= 0.82)) return "Riesgo Medio RCC: #{rcc.round(2)}" elsif ((@genero == 1 && rcc >= 0.95 && rcc <= 1.01) || (@genero == 0 && rcc >= 0.82)) return "Riesgo Alto RCC: #{rcc.round(2)}" elsif ((@genero == 1 && rcc >= 1.01)) return "Riesgo Muy Alto RCC: #{rcc.round(2)}" else return "fuera de rango o algún dato mal introducido" end end |
#subescapular ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 113 def subescapular() subesc = [] for i in 1..3 puts "Introduzca medida #{i} para pliegue Subescapular:" j = gets.to_i subesc.push(j) end sum = subesc.inject(0){ |sum, x| sum + x } @pc_subescapular = (sum/subesc.size.to_f).round(2) return "El pliegue Subescapular medio es -> #{pc_subescapular}mm" end |
#suprailiaco ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 125 def suprailiaco() supraili = [] for i in 1..3 puts "Introduzca medida #{i} para pliegue Suprailiaco:" j = gets.to_i supraili.push(j) end sum = supraili.inject(0){ |sum, x| sum + x } @pc_suprailiaco = (sum/supraili.size.to_f).round(2) return "El pliegue Suprailiaco medio es -> #{pc_suprailiaco}mm" end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 62 def to_s return "{Nombre:#{@nombre}, Apellidos:#{@apellidos}, Edad:#{@edad}, Género:#{@genero}, Peso:#{@peso}, Talla:#{@talla}}" end |
#tricipital ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/alu0100406580_nutricion/paciente.rb', line 101 def tricipital() tricipi = [] for i in 1..3 puts "Introduzca medida #{i} para pliegue tricipital:" j = gets.to_i tricipi.push(j) end sum = tricipi.inject(0){ |sum, x| sum + x } @pc_tricipital = (sum/tricipi.size.to_f).round(2) return "El pliegue Tricipital medio es -> #{pc_tricipital}mm" end |