Class: PacienteM

Inherits:
Paciente show all
Defined in:
lib/alu0101042305/persona.rb

Direct Known Subclasses

PacienteT

Constant Summary collapse

@@factorAct =
{'ninguna' => 0, 'ligera' => 0.12, 'moderada' => 0.27, 'intensa' => 0.54}

Instance Attribute Summary collapse

Attributes inherited from Paciente

#consulta

Attributes inherited from Persona

#nombre, #sexo

Instance Method Summary collapse

Constructor Details

#initialize(nombre, sexo, consulta, peso, talla, edad, cintura, cadera, act = 'ninguna') ⇒ PacienteM

Returns a new instance of PacienteM.



44
45
46
47
# File 'lib/alu0101042305/persona.rb', line 44

def initialize(nombre,sexo,consulta,peso,talla,edad,cintura,cadera,act = 'ninguna')
  super(nombre,sexo,consulta)
  @peso,@talla,@edad,@cintura,@cadera,@act = peso,talla,edad,cintura,cadera,act
end

Instance Attribute Details

#caderaObject (readonly)

Returns the value of attribute cadera.



40
41
42
# File 'lib/alu0101042305/persona.rb', line 40

def cadera
  @cadera
end

#cinturaObject (readonly)

Returns the value of attribute cintura.



40
41
42
# File 'lib/alu0101042305/persona.rb', line 40

def cintura
  @cintura
end

#edadObject (readonly)

Returns the value of attribute edad.



40
41
42
# File 'lib/alu0101042305/persona.rb', line 40

def edad
  @edad
end

Returns the value of attribute menu.



40
41
42
# File 'lib/alu0101042305/persona.rb', line 40

def menu
  @menu
end

#pesoObject (readonly)

Returns the value of attribute peso.



40
41
42
# File 'lib/alu0101042305/persona.rb', line 40

def peso
  @peso
end

#tallaObject (readonly)

Returns the value of attribute talla.



40
41
42
# File 'lib/alu0101042305/persona.rb', line 40

def talla
  @talla
end

Instance Method Details

#<=>(other) ⇒ Object

Raises:

  • (TypeError)


85
86
87
88
89
# File 'lib/alu0101042305/persona.rb', line 85

def <=> other
  raise TypeError, "Se esperaba un objeto Persona" unless other.is_a?Persona
  return self.imc <=> other.imc if other.is_a?PacienteM
  return -1
end

#actividadObject



69
70
71
# File 'lib/alu0101042305/persona.rb', line 69

def actividad
  (basal * @@factorAct[@act]).round(2)
end

#addMenu(menu) ⇒ Object



49
50
51
# File 'lib/alu0101042305/persona.rb', line 49

def addMenu(menu)
  @menu = menu
end

#basalObject



61
62
63
# File 'lib/alu0101042305/persona.rb', line 61

def basal
  (10 * peso + 6.25 * talla * 100 - 5 * edad + (sexo == 'mujer'? -161 : 5)).round(2)
end

#imcObject



77
78
79
# File 'lib/alu0101042305/persona.rb', line 77

def imc
  @peso/(@talla * @talla)
end

Returns:

  • (Boolean)


53
54
55
# File 'lib/alu0101042305/persona.rb', line 53

def menuOk?
  ((total * 0.9)..(total * 1.1)).include? @menu.kcal
end

#pesoIdealObject



57
58
59
# File 'lib/alu0101042305/persona.rb', line 57

def pesoIdeal
  (talla * 100 - 150) * 0.75 + 50
end

#termogenoObject



65
66
67
# File 'lib/alu0101042305/persona.rb', line 65

def termogeno
  (basal * 0.1).round(2)
end

#to_sObject



81
82
83
# File 'lib/alu0101042305/persona.rb', line 81

def to_s
  super.to_s + " y en tratamiento"
end

#totalObject



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

def total
  basal + termogeno + actividad
end