Class: Einutricional::Patient
- Includes:
- Comparable
- Defined in:
- lib/einutricional/patient.rb
Overview
Clase para almacenar los valores antropométricos de una persona
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#hip ⇒ Object
Returns the value of attribute hip.
-
#waist ⇒ Object
Returns the value of attribute waist.
-
#weight ⇒ Object
Returns the value of attribute weight.
Attributes inherited from Person
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Operador de comparación.
- #efecto_termogeno ⇒ Object
- #gasto_actividad_fisica ⇒ Object
- #gasto_energetico ⇒ Object
- #gasto_energetico_basal ⇒ Object
-
#imc ⇒ Fixnum
Indice de Masa Corporal.
-
#initialize(name, surname, sex, age, weight, height, waist, hip, activity) ⇒ Patient
constructor
Constructor que recibe los datos de esa persona.
- #peso_teorico_ideal ⇒ Object
-
#rcc ⇒ Fixnum
Radio Cintura Cadera.
-
#to_s ⇒ String
Imprime los datos del paciente.
Constructor Details
#initialize(name, surname, sex, age, weight, height, waist, hip, activity) ⇒ Patient
Note:
Solo name y surname son [String], el resto son [Fixnum]
Constructor que recibe los datos de esa persona.
9 10 11 12 13 14 15 16 |
# File 'lib/einutricional/patient.rb', line 9 def initialize(name, surname, sex, age, weight, height, waist, hip, activity) super(name, surname, sex, age) @weight = weight @height = height @waist = waist @hip = hip @activity = activity end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
5 6 7 |
# File 'lib/einutricional/patient.rb', line 5 def height @height end |
#hip ⇒ Object
Returns the value of attribute hip.
5 6 7 |
# File 'lib/einutricional/patient.rb', line 5 def hip @hip end |
#waist ⇒ Object
Returns the value of attribute waist.
5 6 7 |
# File 'lib/einutricional/patient.rb', line 5 def waist @waist end |
#weight ⇒ Object
Returns the value of attribute weight.
5 6 7 |
# File 'lib/einutricional/patient.rb', line 5 def weight @weight end |
Instance Method Details
#<=>(other) ⇒ Object
Operador de comparación
20 21 22 |
# File 'lib/einutricional/patient.rb', line 20 def <=>(other) imc <=> other.imc end |
#efecto_termogeno ⇒ Object
52 53 54 |
# File 'lib/einutricional/patient.rb', line 52 def efecto_termogeno (gasto_energetico_basal * 0.10).round(0) end |
#gasto_actividad_fisica ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/einutricional/patient.rb', line 56 def gasto_actividad_fisica f = case @activity when 'reposo' 0.0 when 'ligera' 0.12 when 'moderada' 0.27 when 'intensa' 0.54 else 0.0 end (gasto_energetico_basal * f).round(0) end |
#gasto_energetico ⇒ Object
72 73 74 |
# File 'lib/einutricional/patient.rb', line 72 def gasto_energetico (gasto_energetico_basal + efecto_termogeno + gasto_actividad_fisica).round(0) end |
#gasto_energetico_basal ⇒ Object
46 47 48 49 50 |
# File 'lib/einutricional/patient.rb', line 46 def gasto_energetico_basal geb = (10 * @weight) + (6.25 * @height * 100) - (5 * @age) geb += (@age == 'h' ? 5 : -161) geb.round(0) end |
#imc ⇒ Fixnum
Indice de Masa Corporal
26 27 28 |
# File 'lib/einutricional/patient.rb', line 26 def imc (@weight.to_f / @height ** 2).round(2) end |
#peso_teorico_ideal ⇒ Object
42 43 44 |
# File 'lib/einutricional/patient.rb', line 42 def peso_teorico_ideal (@height * 100 - 150) * 0.75 + 50 end |
#rcc ⇒ Fixnum
Radio Cintura Cadera
32 33 34 |
# File 'lib/einutricional/patient.rb', line 32 def rcc (@waist.to_f / @hip).round(2) end |
#to_s ⇒ String
Imprime los datos del paciente
38 39 40 |
# File 'lib/einutricional/patient.rb', line 38 def to_s "#{@surname}, #{@name}, #{@sex}, #{@age}, #{@weight}, #{@height}, #{@waist}, #{@hip}" end |