Class: Einutricional::Patient

Inherits:
Person
  • Object
show all
Includes:
Comparable
Defined in:
lib/einutricional/patient.rb

Overview

Clase para almacenar los valores antropométricos de una persona

Instance Attribute Summary collapse

Attributes inherited from Person

#age, #name, #sex, #surname

Instance Method Summary collapse

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

#heightObject

Returns the value of attribute height.



5
6
7
# File 'lib/einutricional/patient.rb', line 5

def height
  @height
end

#hipObject

Returns the value of attribute hip.



5
6
7
# File 'lib/einutricional/patient.rb', line 5

def hip
  @hip
end

#waistObject

Returns the value of attribute waist.



5
6
7
# File 'lib/einutricional/patient.rb', line 5

def waist
  @waist
end

#weightObject

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

Returns:

  • -1, 0, 1 según si el imc del paciente ‘self’ es menor, igual o mayor que el del paciente con el que se compara



20
21
22
# File 'lib/einutricional/patient.rb', line 20

def <=>(other)
  imc <=> other.imc
end

#efecto_termogenoObject



52
53
54
# File 'lib/einutricional/patient.rb', line 52

def efecto_termogeno
  (gasto_energetico_basal * 0.10).round(0)
end

#gasto_actividad_fisicaObject



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_energeticoObject



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_basalObject



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

#imcFixnum

Indice de Masa Corporal

Returns:

  • (Fixnum)

    el IMC



26
27
28
# File 'lib/einutricional/patient.rb', line 26

def imc
  (@weight.to_f / @height ** 2).round(2)
end

#peso_teorico_idealObject



42
43
44
# File 'lib/einutricional/patient.rb', line 42

def peso_teorico_ideal
  (@height * 100 - 150) * 0.75 + 50
end

#rccFixnum

Radio Cintura Cadera

Returns:

  • (Fixnum)

    el RCC



32
33
34
# File 'lib/einutricional/patient.rb', line 32

def rcc
  (@waist.to_f / @hip).round(2)
end

#to_sString

Imprime los datos del paciente

Returns:

  • (String)

    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