Class: Edad
Overview
CLASE DE GRUPO BASADA EN EDAD
Instance Attribute Summary collapse
-
#edad ⇒ Object
readonly
Metodo de acceso a al variable de instancia.
Attributes inherited from Dieta
#cantidad, #descripcion, #ingesta, #kcal, #percent, #racion, #tipo_dieta
Instance Method Summary collapse
-
#<<(dieta) ⇒ Object
Metodo instancia, permite insertar una dieta.
-
#<=>(otro) ⇒ Object
Comparable___.
-
#change_edad(a, b) ⇒ Object
Metodo instancia, permite cambiar el atributo de rango de edad del grupo de edades.
-
#initialize(edad) ⇒ Edad
constructor
A new instance of Edad.
Methods inherited from Dieta
#get_descripcion, #get_gras, #get_hidr, #get_platos, #get_prot, #get_titulo, #get_to_, #to_s
Constructor Details
#initialize(edad) ⇒ Edad
Returns a new instance of Edad.
135 136 137 138 |
# File 'lib/pract06/menu.rb', line 135 def initialize(edad) super(0,0,0,0,0,0,0) @edad=edad end |
Instance Attribute Details
#edad ⇒ Object (readonly)
Metodo de acceso a al variable de instancia
133 134 135 |
# File 'lib/pract06/menu.rb', line 133 def edad @edad end |
Instance Method Details
#<<(dieta) ⇒ Object
Metodo instancia, permite insertar una dieta
161 162 163 |
# File 'lib/pract06/menu.rb', line 161 def <<(dieta) super(dieta.tipo_dieta, dieta.ingesta, dieta.descripcion, dieta.racion, dieta.cantidad, dieta.kcal, dieta.percent) end |
#<=>(otro) ⇒ Object
Comparable___
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/pract06/menu.rb', line 147 def <=>(otro) #Implementanto este apartado, elaboramos un metodo #que distingue no solo entre calorias si no #tambien en el porcentaje de grasas, proteinas, etc. if(self.kcal == otro.kcal) #self.get_prot <=> otro.get_prot #self.get_gras <=> otro.get_gras self.get_hidr <=> otro.get_hidr else self.kcal <=> otro.kcal end end |
#change_edad(a, b) ⇒ Object
Metodo instancia, permite cambiar el atributo de rango de edad del grupo de edades.
141 142 143 |
# File 'lib/pract06/menu.rb', line 141 def change_edad(a,b) @edad= "de #{a} a #{b} aƱos" end |