Class: Menudsl
Instance Attribute Summary collapse
-
#etiqueta ⇒ Object
Returns the value of attribute etiqueta.
-
#pGrasas ⇒ Object
Returns the value of attribute pGrasas.
-
#pHidratos ⇒ Object
Returns the value of attribute pHidratos.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
-
#pProteinas ⇒ Object
Returns the value of attribute pProteinas.
-
#tit ⇒ Object
Returns the value of attribute tit.
-
#vct ⇒ Object
Returns the value of attribute vct.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #ingesta(opciones = {}) ⇒ Object
-
#initialize(etiqueta, &block) ⇒ Menudsl
constructor
A new instance of Menudsl.
- #plato(opciones = {}) ⇒ Object
- #porcentajes(opciones = {}) ⇒ Object
- #titulo(titul) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(etiqueta, &block) ⇒ Menudsl
Returns a new instance of Menudsl.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/menu/menudsl.rb', line 5 def initialize(etiqueta, &block) self.etiqueta = etiqueta self.tit self.porcentaje self.platos = [] self.vct if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#etiqueta ⇒ Object
Returns the value of attribute etiqueta.
3 4 5 |
# File 'lib/menu/menudsl.rb', line 3 def etiqueta @etiqueta end |
#pGrasas ⇒ Object
Returns the value of attribute pGrasas.
3 4 5 |
# File 'lib/menu/menudsl.rb', line 3 def pGrasas @pGrasas end |
#pHidratos ⇒ Object
Returns the value of attribute pHidratos.
3 4 5 |
# File 'lib/menu/menudsl.rb', line 3 def pHidratos @pHidratos end |
#platos ⇒ Object
Returns the value of attribute platos.
3 4 5 |
# File 'lib/menu/menudsl.rb', line 3 def platos @platos end |
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
3 4 5 |
# File 'lib/menu/menudsl.rb', line 3 def porcentaje @porcentaje end |
#pProteinas ⇒ Object
Returns the value of attribute pProteinas.
3 4 5 |
# File 'lib/menu/menudsl.rb', line 3 def pProteinas @pProteinas end |
#tit ⇒ Object
Returns the value of attribute tit.
3 4 5 |
# File 'lib/menu/menudsl.rb', line 3 def tit @tit end |
#vct ⇒ Object
Returns the value of attribute vct.
3 4 5 |
# File 'lib/menu/menudsl.rb', line 3 def vct @vct end |
Instance Method Details
#<=>(other) ⇒ Object
55 56 57 58 59 |
# File 'lib/menu/menudsl.rb', line 55 def <=>(other) if(other.instance_of? Menudsl) @vct <=> other.vct end end |
#ingesta(opciones = {}) ⇒ Object
25 26 27 |
# File 'lib/menu/menudsl.rb', line 25 def ingesta(opciones = {}) @porcentaje = "(#{opciones[:min]}% - #{opciones[:max]}%)" end |
#plato(opciones = {}) ⇒ Object
29 30 31 32 |
# File 'lib/menu/menudsl.rb', line 29 def plato(opciones = {}) plato= Plato.new(opciones[:nombre], opciones[:porcion], "#{opciones[:gramos]} gramos") platos << plato end |
#porcentajes(opciones = {}) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/menu/menudsl.rb', line 34 def porcentajes(opciones = {}) @vct = "#{opciones[:vct]} Kcal" @pProteinas = "#{opciones[:proteinas]}%" @pGrasas = "#{opciones[:grasas]}%" @pHidratos = "#{opciones[:hidratos]}%" end |
#titulo(titul) ⇒ Object
21 22 23 |
# File 'lib/menu/menudsl.rb', line 21 def titulo(titul) @tit = titul end |
#to_s ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/menu/menudsl.rb', line 41 def to_s i = 0 salida = "#{@tit} (#{@porcentaje})\n" while i < @platos.length do salida += @platos[i].to_s + "\n" i += 1 end salida += "V.C.T. ( #{@vct} ) #{@pProteinas} - #{@pGrasas} - #{@pHidratos}" salida end |