Class: Diet
Instance Attribute Summary collapse
-
#gramos ⇒ Object
readonly
Returns the value of attribute gramos.
-
#grasas ⇒ Object
readonly
Returns the value of attribute grasas.
-
#hidratos ⇒ Object
readonly
Returns the value of attribute hidratos.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#platos ⇒ Object
readonly
Returns the value of attribute platos.
-
#porcentaje ⇒ Object
readonly
Returns the value of attribute porcentaje.
-
#porcion ⇒ Object
readonly
Returns the value of attribute porcion.
-
#proteinas ⇒ Object
readonly
Returns the value of attribute proteinas.
-
#vct ⇒ Object
readonly
Returns the value of attribute vct.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
definimos el metodo necesario para comparar.
-
#initialize(nombre, porcentaje, platos, porcion, gramos, vct, proteinas, grasas, hidratos) ⇒ Diet
constructor
A new instance of Diet.
-
#to_s ⇒ Object
Metodo para imprimir.
Constructor Details
#initialize(nombre, porcentaje, platos, porcion, gramos, vct, proteinas, grasas, hidratos) ⇒ Diet
Returns a new instance of Diet.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/prct7/diet.rb', line 4 def initialize(nombre,porcentaje,platos,porcion,gramos,vct,proteinas,grasas,hidratos) @nombre = nombre @porcentaje = porcentaje @platos = platos @porcion = porcion @gramos = gramos @vct = vct @proteinas = proteinas @grasas = grasas @hidratos = hidratos end |
Instance Attribute Details
#gramos ⇒ Object (readonly)
Returns the value of attribute gramos.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def gramos @gramos end |
#grasas ⇒ Object (readonly)
Returns the value of attribute grasas.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def grasas @grasas end |
#hidratos ⇒ Object (readonly)
Returns the value of attribute hidratos.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def hidratos @hidratos end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def nombre @nombre end |
#platos ⇒ Object (readonly)
Returns the value of attribute platos.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def platos @platos end |
#porcentaje ⇒ Object (readonly)
Returns the value of attribute porcentaje.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def porcentaje @porcentaje end |
#porcion ⇒ Object (readonly)
Returns the value of attribute porcion.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def porcion @porcion end |
#proteinas ⇒ Object (readonly)
Returns the value of attribute proteinas.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def proteinas @proteinas end |
#vct ⇒ Object (readonly)
Returns the value of attribute vct.
3 4 5 |
# File 'lib/prct7/diet.rb', line 3 def vct @vct end |
Instance Method Details
#<=>(other) ⇒ Object
definimos el metodo necesario para comparar
25 26 27 |
# File 'lib/prct7/diet.rb', line 25 def <=>(other) @vct <=> other.vct end |
#to_s ⇒ Object
Metodo para imprimir
16 17 18 19 20 21 22 23 |
# File 'lib/prct7/diet.rb', line 16 def to_s s="\n#{@nombre} (#{@porcentaje})\n" (0..@platos.size-1).each do |i| s<< "#{@platos[i]}, #{@porcion[i]}, #{@gramos[i]}gr.\n" end s<< "VCT | %\t#{@vct} kcal | #{@proteinas}% - #{@grasas}% - #{@hidratos}%\n" s end |