Class: Dieta
Direct Known Subclasses
Instance Attribute Summary collapse
-
#gramos ⇒ Object
Returns the value of attribute gramos.
-
#kcal ⇒ Object
Returns the value of attribute kcal.
-
#pgh ⇒ Object
Returns the value of attribute pgh.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
-
#porcion ⇒ Object
Returns the value of attribute porcion.
-
#titulo ⇒ Object
Returns the value of attribute titulo.
Instance Method Summary collapse
- #<=>(anOther) ⇒ Object
- #==(anOther) ⇒ Object
-
#initialize(titulo, porcentaje, platos, porcion, gramos, kcal, pgh) ⇒ Dieta
constructor
A new instance of Dieta.
- #to_s ⇒ Object
Constructor Details
#initialize(titulo, porcentaje, platos, porcion, gramos, kcal, pgh) ⇒ Dieta
Returns a new instance of Dieta.
5 6 7 8 9 10 11 12 13 |
# File 'lib/MenuDieta/dieta.rb', line 5 def initialize(titulo, porcentaje, platos, porcion, gramos, kcal, pgh) @titulo = titulo @porcentaje = porcentaje @platos = platos @porcion = porcion @gramos = gramos @kcal = kcal @pgh = pgh end |
Instance Attribute Details
#gramos ⇒ Object
Returns the value of attribute gramos.
3 4 5 |
# File 'lib/MenuDieta/dieta.rb', line 3 def gramos @gramos end |
#kcal ⇒ Object
Returns the value of attribute kcal.
3 4 5 |
# File 'lib/MenuDieta/dieta.rb', line 3 def kcal @kcal end |
#pgh ⇒ Object
Returns the value of attribute pgh.
3 4 5 |
# File 'lib/MenuDieta/dieta.rb', line 3 def pgh @pgh end |
#platos ⇒ Object
Returns the value of attribute platos.
3 4 5 |
# File 'lib/MenuDieta/dieta.rb', line 3 def platos @platos end |
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
3 4 5 |
# File 'lib/MenuDieta/dieta.rb', line 3 def porcentaje @porcentaje end |
#porcion ⇒ Object
Returns the value of attribute porcion.
3 4 5 |
# File 'lib/MenuDieta/dieta.rb', line 3 def porcion @porcion end |
#titulo ⇒ Object
Returns the value of attribute titulo.
3 4 5 |
# File 'lib/MenuDieta/dieta.rb', line 3 def titulo @titulo end |
Instance Method Details
#<=>(anOther) ⇒ Object
34 35 36 |
# File 'lib/MenuDieta/dieta.rb', line 34 def <=> (anOther) self.kcal <=> anOther.kcal end |
#==(anOther) ⇒ Object
38 39 40 |
# File 'lib/MenuDieta/dieta.rb', line 38 def == (anOther) return (kcal==anOther.kcal) && (pgh == anOther.pgh) end |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/MenuDieta/dieta.rb', line 15 def to_s aux = "#{titulo} (#{porcentaje})\n" i = 0 while i < @platos.size aux = aux + "- #{@platos[i]}, #{@porcion[i]}, #{@gramos[i]} g\n" i = i + 1 end aux = aux + "V.C.T. | % #{kcal} Kcal |" i = 0 while i < @pgh.size aux = aux + " #{@pgh[i]}%" if(i < @pgh.size-1) aux = aux + " -" end i = i + 1 end return aux end |