Class: Diet
Direct Known Subclasses
Instance Attribute Summary collapse
-
#calorias ⇒ Object
Returns the value of attribute calorias.
-
#comida ⇒ Object
Returns the value of attribute comida.
-
#porciones ⇒ Object
Returns the value of attribute porciones.
Instance Method Summary collapse
- #<=>(anOther) ⇒ Object
- #==(anOther) ⇒ Object
-
#calorias_to_s ⇒ Object
calorias_to_s.
-
#comida_to_s ⇒ Object
comida_to_s.
-
#initialize(comida, porciones, calorias) ⇒ Diet
constructor
A new instance of Diet.
-
#porciones_to_s ⇒ Object
porciones_to_s.
Constructor Details
#initialize(comida, porciones, calorias) ⇒ Diet
Returns a new instance of Diet.
4 5 6 7 8 9 |
# File 'lib/dieta/dieta.rb', line 4 def initialize(comida,porciones,calorias) #atributos @comida = comida @porciones = porciones @calorias = calorias end |
Instance Attribute Details
#calorias ⇒ Object
Returns the value of attribute calorias.
3 4 5 |
# File 'lib/dieta/dieta.rb', line 3 def calorias @calorias end |
#comida ⇒ Object
Returns the value of attribute comida.
3 4 5 |
# File 'lib/dieta/dieta.rb', line 3 def comida @comida end |
#porciones ⇒ Object
Returns the value of attribute porciones.
3 4 5 |
# File 'lib/dieta/dieta.rb', line 3 def porciones @porciones end |
Instance Method Details
#<=>(anOther) ⇒ Object
53 54 55 |
# File 'lib/dieta/dieta.rb', line 53 def <=> (anOther) self.calorias <=> anOther.calorias end |
#==(anOther) ⇒ Object
57 58 59 |
# File 'lib/dieta/dieta.rb', line 57 def ==(anOther) return (calorias== anOther.calorias) end |
#calorias_to_s ⇒ Object
calorias_to_s
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dieta/dieta.rb', line 40 def calorias_to_s i = 0 aux = "V.C.T:" while i < (@calorias.size - 1) aux = "#{aux}" + "#{" "}" + "#{@calorias[i]}" + "#{","}" i = i + 1 end aux="#{aux}" + "#{" "}" + "#{@calorias[i]}" return aux end |
#comida_to_s ⇒ Object
comida_to_s
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dieta/dieta.rb', line 12 def comida_to_s i = 0 aux="#{@comida[i]}" i=i+1 while i < @comida.size aux = "#{aux}" + "#{" "}" + "#{@comida[i]}" i = i + 1 end aux="#{aux}" + "#{"\n"}" return aux end |
#porciones_to_s ⇒ Object
porciones_to_s
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dieta/dieta.rb', line 27 def porciones_to_s i = 0 aux = "Porciones:\n" while i < @porciones.size aux = "#{aux}" + "#{" "}" + "#{@porciones[i][0]}" + "#{", "}" + "#{@porciones[i][1]}\n" i = i + 1 end return aux end |