Class: Paciente

Inherits:
Persona show all
Includes:
Comparable
Defined in:
lib/alu0100987522/individuo.rb

Instance Attribute Summary collapse

Attributes inherited from Persona

#apellido, #edad, #genero, #nombre

Instance Method Summary collapse

Constructor Details

#initialize(nombre, apellido, edad, genero, peso, talla, actfis) ⇒ Paciente

Returns a new instance of Paciente.



26
27
28
29
30
31
32
33
# File 'lib/alu0100987522/individuo.rb', line 26

def initialize(nombre, apellido, edad, genero, peso, talla, actfis)
   super(nombre, apellido, edad, genero)
   @peso = peso
   @talla = talla
   @actfis = actfis
   @genero = genero
   @edad = edad
end

Instance Attribute Details

#actfisObject (readonly)

Returns the value of attribute actfis.



24
25
26
# File 'lib/alu0100987522/individuo.rb', line 24

def actfis
  @actfis
end

#pesoObject (readonly)

Returns the value of attribute peso.



24
25
26
# File 'lib/alu0100987522/individuo.rb', line 24

def peso
  @peso
end

#tallaObject (readonly)

Returns the value of attribute talla.



24
25
26
# File 'lib/alu0100987522/individuo.rb', line 24

def talla
  @talla
end

Instance Method Details

#<=>(another) ⇒ Object



61
62
63
# File 'lib/alu0100987522/individuo.rb', line 61

def <=>(another)
imc_calculo <=> another.imc_calculo
end

#efecto_termogenoObject



76
77
78
# File 'lib/alu0100987522/individuo.rb', line 76

def efecto_termogeno
    gasto_energetico_basal() * 0.10
end

#gasto_actividad_fisicaObject



80
81
82
# File 'lib/alu0100987522/individuo.rb', line 80

def gasto_actividad_fisica
   gasto_energetico_basal() * actfis 
end

#gasto_energetico_basalObject



65
66
67
68
69
70
71
72
73
74
# File 'lib/alu0100987522/individuo.rb', line 65

def gasto_energetico_basal 
    geb = 0
    if genero == "Masculino"
        geb = 10.0*peso + 6.25*talla - 5.0*edad + 5
    end
    if genero == "Femenino"
        geb = 10.0*peso + 6.25*talla - 5.0*edad - 161
    end
    return geb
end

#gasto_energetico_totalObject



84
85
86
# File 'lib/alu0100987522/individuo.rb', line 84

def gasto_energetico_total
    gasto_energetico_basal() + efecto_termogeno() + gasto_actividad_fisica()
end

#imc_calculoObject



35
36
37
# File 'lib/alu0100987522/individuo.rb', line 35

def imc_calculo
   return @peso/(@talla*@talla) 
end

#imc_clasificarObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/alu0100987522/individuo.rb', line 39

def imc_clasificar
    imc = imc_calculo()
    tipo = "";
    if (imc<18.5)
      tipo = "Delgado"
    elsif(imc.between?(18.5, 24.9))
      tipo = "Aceptable"
    elsif(imc.between?(25.0, 29.9))
      tipo = "Sobrepeso"
    elsif (imc>29.9)
      tipo = "Obesidad"
    else
      return "Error clasificando el imc:  #{imc}."
    end
    
    return tipo
end

#to_sObject



57
58
59
# File 'lib/alu0100987522/individuo.rb', line 57

def to_s
    return %Q(#{@nombre} #{@apellido} - Edad: #{@edad} años - Género: #{@genero} - Peso: #{@peso} kg - Talla: #{@talla} m - Factor act. física: #{@actfis}.)
end