Class: MenuProc
Instance Attribute Summary collapse
-
#grasas ⇒ Object
Returns the value of attribute grasas.
-
#hidratos ⇒ Object
Returns the value of attribute hidratos.
-
#ingestas ⇒ Object
Returns the value of attribute ingestas.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#proteinas ⇒ Object
Returns the value of attribute proteinas.
-
#titulos ⇒ Object
Returns the value of attribute titulos.
-
#vct ⇒ Object
Returns the value of attribute vct.
Instance Method Summary collapse
- #ingesta(options = {}) ⇒ Object
-
#initialize(titulo, &bloque) ⇒ MenuProc
constructor
A new instance of MenuProc.
- #plato(options = {}) ⇒ Object
- #porcentajes(options = {}) ⇒ Object
- #titulo(options = {}) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Dieta
Constructor Details
#initialize(titulo, &bloque) ⇒ MenuProc
Returns a new instance of MenuProc.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/menu/Menu_Proc.rb', line 4 def initialize(titulo, &bloque) self.titulos = "" self.vct = [] self.ingestas = [] self.proteinas = [] self.grasas = [] self.hidratos = [] self.platos = [] if block_given? if bloque.arity == 1 yield self else instance_eval(&bloque) end end end |
Instance Attribute Details
#grasas ⇒ Object
Returns the value of attribute grasas.
3 4 5 |
# File 'lib/menu/Menu_Proc.rb', line 3 def grasas @grasas end |
#hidratos ⇒ Object
Returns the value of attribute hidratos.
3 4 5 |
# File 'lib/menu/Menu_Proc.rb', line 3 def hidratos @hidratos end |
#ingestas ⇒ Object
Returns the value of attribute ingestas.
3 4 5 |
# File 'lib/menu/Menu_Proc.rb', line 3 def ingestas @ingestas end |
#platos ⇒ Object
Returns the value of attribute platos.
3 4 5 |
# File 'lib/menu/Menu_Proc.rb', line 3 def platos @platos end |
#proteinas ⇒ Object
Returns the value of attribute proteinas.
3 4 5 |
# File 'lib/menu/Menu_Proc.rb', line 3 def proteinas @proteinas end |
#titulos ⇒ Object
Returns the value of attribute titulos.
3 4 5 |
# File 'lib/menu/Menu_Proc.rb', line 3 def titulos @titulos end |
#vct ⇒ Object
Returns the value of attribute vct.
3 4 5 |
# File 'lib/menu/Menu_Proc.rb', line 3 def vct @vct end |
Instance Method Details
#ingesta(options = {}) ⇒ Object
26 27 28 29 |
# File 'lib/menu/Menu_Proc.rb', line 26 def ingesta( = {}) self.ingestas << [:min] if [:min] self.ingestas << [:max] if [:max] end |
#plato(options = {}) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/menu/Menu_Proc.rb', line 31 def plato( = {}) desc = "#{[:descripcion]}" if [:descripcion] porc = "#{[:porcion]}" if [:porcion] gra = [:gramos] if [:gramos] self.platos << Plato.new(desc, porc, gra) end |
#porcentajes(options = {}) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/menu/Menu_Proc.rb', line 37 def porcentajes( = {}) self.vct = [:vct] if [:vct] self.proteinas = [:proteinas] if [:proteinas] self.grasas = [:grasas] if [:grasas] self.hidratos = [:hidratos] if [:hidratos] end |
#titulo(options = {}) ⇒ Object
22 23 24 |
# File 'lib/menu/Menu_Proc.rb', line 22 def titulo( = {}) self.titulos = "#{[:name]}" if [:name] end |
#to_s ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/menu/Menu_Proc.rb', line 43 def to_s s = "#{titulos} (#{ingestas[0]}% - #{ingestas[1]}%)\n" platos.each_with_index do |comida| s << "- #{comida.descripcion}, #{comida.porcion}, #{comida.gramos} g\n" end s << "V.C.T. | % #{vct} kcal | #{proteinas}% - #{grasas}% - #{hidratos}%" end |