Class: Individuo
- Includes:
- Comparable
- Defined in:
- lib/individuo.rb,
lib/nutrientesEugenio/version.rb
Overview
Representación de un individuo
Constant Summary collapse
- VERSION =
Version de la clase Individuo
"0.1.0"
Instance Attribute Summary collapse
-
#Boolean ⇒ Object
readonly
paciente Determina si el individuo es un paciente o no.
- #nombre ⇒ Object readonly
- #paciente ⇒ Object readonly
-
#String ⇒ Object
readonly
nombre Nombre del individuo.
- #t_obesidad ⇒ Object readonly
Attributes inherited from IMC
#a, #altura, #b, #c, #d, #edad, #peso, #sexo
Instance Method Summary collapse
-
#<=>(other) ⇒ -1, ...
Metodo para comparar dos individuos.
-
#cat_peso ⇒ String
Metodo que clasifica individuos segun su imc.
-
#efecto_termogeno ⇒ Number
Metodo para calcular el efecto termogeno.
-
#gasto_actividad_fisica(cantidad) ⇒ Number
Metodo para calcular el gasto de la actividad fisica.
-
#gasto_energetico_total(cantidad) ⇒ Number
Metodo para calcular el gasto total del individuo.
-
#initialize(nombre, paciente, t_obesidad, a, b, c, d) ⇒ Individuo
constructor
Constructor de un individuo.
-
#peso_ideal ⇒ Number
Metodo para calcular peso ideal.
-
#tmb ⇒ Number
Metodo para calcular la tmb.
-
#to_s ⇒ String
Convierte el objeto a una cadena de caracteres.
Methods inherited from IMC
#calcular_imc, #porcentaje_graso
Constructor Details
#initialize(nombre, paciente, t_obesidad, a, b, c, d) ⇒ Individuo
Constructor de un individuo
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
#Boolean ⇒ Object (readonly)
paciente Determina si el individuo es un paciente o no
10 11 12 |
# File 'lib/individuo.rb', line 10 def Boolean @Boolean end |
#nombre ⇒ Object (readonly)
12 13 14 |
# File 'lib/individuo.rb', line 12 def nombre @nombre end |
#paciente ⇒ Object (readonly)
12 13 14 |
# File 'lib/individuo.rb', line 12 def paciente @paciente end |
#String ⇒ Object (readonly)
nombre Nombre del individuo
10 11 12 |
# File 'lib/individuo.rb', line 10 def String @String end |
#t_obesidad ⇒ Object (readonly)
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
66 67 68 |
# File 'lib/individuo.rb', line 66 def <=>(other) calcular_imc <=> other.calcular_imc end |
#cat_peso ⇒ String
Metodo que clasifica individuos segun su imc
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_termogeno ⇒ Number
Metodo para calcular el efecto termogeno
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
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
111 112 113 |
# File 'lib/individuo.rb', line 111 def gasto_energetico_total(cantidad) tmb + efecto_termogeno + gasto_actividad_fisica(cantidad) end |
#peso_ideal ⇒ Number
Metodo para calcular peso ideal
73 74 75 |
# File 'lib/individuo.rb', line 73 def peso_ideal ((@altura * 100) - 150) * 0.75 + 50 end |
#tmb ⇒ Number
Metodo para calcular la tmb
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_s ⇒ String
Convierte el objeto a una cadena de caracteres
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 |