Class: Individuo

Inherits:
IMC
  • Object
show all
Includes:
Comparable
Defined in:
lib/individuo.rb,
lib/nutrientesEugenio/version.rb

Overview

Representación de un individuo

Author:

  • Eugenio José Gonzalez Luis

Since:

  • 1.0.0

Constant Summary collapse

VERSION =

Version de la clase Individuo

Since:

  • 1.0.0

"0.1.0"

Instance Attribute Summary collapse

Attributes inherited from IMC

#a, #altura, #b, #c, #d, #edad, #peso, #sexo

Instance Method Summary collapse

Methods inherited from IMC

#calcular_imc, #porcentaje_graso

Constructor Details

#initialize(nombre, paciente, t_obesidad, a, b, c, d) ⇒ Individuo

Constructor de un individuo

Parameters:

  • nombre (String)

    Nombre del individuo

  • paciente (Boolean)

    Determina si el individuo es un paciente o no

  • t_obesidad (Boolean)

    Determina si el individuo esta recibiendo tratamiendo de obesidad o no

  • a (Number)

    peso del paciente

  • b (Number)

    altura del paciente

  • c (Number)

    edad del paciente

  • d (1, 0)

    sexo del paciente

Since:

  • 1.0.0



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

def initialize(nombre, paciente, t_obesidad, a, b, c, d)
    @nombre = nombre
    @paciente = paciente
    @t_obesidad = t_obesidad
    if t_obesidad
        super(a,b,c,d)
    end
end

Instance Attribute Details

#BooleanObject (readonly)

paciente Determina si el individuo es un paciente o no

Returns:

  • (Object)

    the current value of Boolean



10
11
12
# File 'lib/individuo.rb', line 10

def Boolean
  @Boolean
end

#nombreObject (readonly)

Since:

  • 1.0.0



12
13
14
# File 'lib/individuo.rb', line 12

def nombre
  @nombre
end

#pacienteObject (readonly)

Since:

  • 1.0.0



12
13
14
# File 'lib/individuo.rb', line 12

def paciente
  @paciente
end

#StringObject (readonly)

nombre Nombre del individuo

Returns:

  • (Object)

    the current value of String



10
11
12
# File 'lib/individuo.rb', line 10

def String
  @String
end

#t_obesidadObject (readonly)

Since:

  • 1.0.0



12
13
14
# File 'lib/individuo.rb', line 12

def t_obesidad
  @t_obesidad
end

Instance Method Details

#<=>(other) ⇒ -1, ...

Metodo para comparar dos individuos

Parameters:

Returns:

  • (-1, 0, 1)

    -1 si es menor, 0 si son iguales, 1 si es mayor

Since:

  • 1.0.0



66
67
68
# File 'lib/individuo.rb', line 66

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

#cat_pesoString

Metodo que clasifica individuos segun su imc

Returns:

  • (String)

    devuelve un string con la clasificación

Since:

  • 1.0.0



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/individuo.rb', line 37

def cat_peso
    if(!t_obesidad)
        return "Sin datos recogidos"
    elsif(calcular_imc < 18.5)
        return "Bajo peso"
    elsif(calcular_imc < 24.9)
        return "Saludable"
    elsif(calcular_imc < 29.9)
        return "Sobrepeso"
    elsif(calcular_imc < 39.9)
        return "Obesidad"
    else 
        return "Obesidad Extrema"
    end
end

#efecto_termogenoNumber

Metodo para calcular el efecto termogeno

Returns:

  • (Number)

    efecto termogeno del individuo

Since:

  • 1.0.0



87
88
89
# File 'lib/individuo.rb', line 87

def efecto_termogeno
    tmb * 0.1
end

#gasto_actividad_fisica(cantidad) ⇒ Number

Metodo para calcular el gasto de la actividad fisica

Parameters:

  • tipo (String)

    de actividad fisica realizado

Returns:

  • (Number)

    el gasto de la actividad fisica del individuo

Since:

  • 1.0.0



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/individuo.rb', line 95

def gasto_actividad_fisica(cantidad)
    if (cantidad == "reposo")
        return 0
    elsif (cantidad == "ligera")
        return tmb * 0.12
    elsif (cantidad == "moderada")
        return tmb * 0.27
    else
        return tmb * 0.54
    end
end

#gasto_energetico_total(cantidad) ⇒ Number

Metodo para calcular el gasto total del individuo

Parameters:

  • tipo (String)

    de actividad fisica realizado

Returns:

  • (Number)

    el gasto total del individuo del individuo

Since:

  • 1.0.0



111
112
113
# File 'lib/individuo.rb', line 111

def gasto_energetico_total(cantidad)
    tmb + efecto_termogeno + gasto_actividad_fisica(cantidad)
end

#peso_idealNumber

Metodo para calcular peso ideal

Returns:

  • (Number)

    peso ideal del individuo

Since:

  • 1.0.0



73
74
75
# File 'lib/individuo.rb', line 73

def peso_ideal
    ((@altura * 100) - 150) * 0.75 + 50
end

#tmbNumber

Metodo para calcular la tmb

Returns:

  • (Number)

    tmb del individuo

Since:

  • 1.0.0



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

def tmb
    10*@peso + ((@altura * 100) * 6.25) - 5 * @edad + 5 + ((1-@sexo) * 166)
end

#to_sString

Convierte el objeto a una cadena de caracteres

Returns:

  • (String)

    devuelve el individuo como un string

Since:

  • 1.0.0



55
56
57
58
59
60
61
# File 'lib/individuo.rb', line 55

def to_s
    rval = "#{@nombre}"
    if(t_obesidad)
        rval += super
    end
    rval
end