Class: Menu_DSL
- Inherits:
-
Object
- Object
- Menu_DSL
- Defined in:
- lib/menus/menu_dsl.rb
Instance Attribute Summary collapse
-
#descripcion ⇒ Object
Returns the value of attribute descripcion.
-
#gramos ⇒ Object
Returns the value of attribute gramos.
-
#grasas ⇒ Object
Returns the value of attribute grasas.
-
#hidratos ⇒ Object
Returns the value of attribute hidratos.
-
#ingesta_porcentajes ⇒ Object
Returns the value of attribute ingesta_porcentajes.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#porcion ⇒ Object
Returns the value of attribute porcion.
-
#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(titulos, &block) ⇒ Menu_DSL
constructor
A new instance of Menu_DSL.
- #plato(options = {}) ⇒ Object
- #porcentajes(options = {}) ⇒ Object
- #titulo(name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(titulos, &block) ⇒ Menu_DSL
Returns a new instance of Menu_DSL.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/menus/menu_dsl.rb', line 4 def initialize(titulos, &block) self.titulos = titulos self.platos = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#descripcion ⇒ Object
Returns the value of attribute descripcion.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def descripcion @descripcion end |
#gramos ⇒ Object
Returns the value of attribute gramos.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def gramos @gramos end |
#grasas ⇒ Object
Returns the value of attribute grasas.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def grasas @grasas end |
#hidratos ⇒ Object
Returns the value of attribute hidratos.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def hidratos @hidratos end |
#ingesta_porcentajes ⇒ Object
Returns the value of attribute ingesta_porcentajes.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def ingesta_porcentajes @ingesta_porcentajes end |
#platos ⇒ Object
Returns the value of attribute platos.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def platos @platos end |
#porcion ⇒ Object
Returns the value of attribute porcion.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def porcion @porcion end |
#proteinas ⇒ Object
Returns the value of attribute proteinas.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def proteinas @proteinas end |
#titulos ⇒ Object
Returns the value of attribute titulos.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def titulos @titulos end |
#vct ⇒ Object
Returns the value of attribute vct.
2 3 4 |
# File 'lib/menus/menu_dsl.rb', line 2 def vct @vct end |
Instance Method Details
#ingesta(options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/menus/menu_dsl.rb', line 21 def ingesta( = {}) min_max = [] min_max << "#{[:min]}" min_max << "#{[:max]}" @ingesta_porcentajes = min_max end |
#plato(options = {}) ⇒ Object
28 29 30 31 32 |
# File 'lib/menus/menu_dsl.rb', line 28 def plato( = {}) ingredientes = [] ingredientes << "#{[:descripcion]}, #{[:porcion]}, #{[:gramos]}" @platos.push(ingredientes) end |
#porcentajes(options = {}) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/menus/menu_dsl.rb', line 34 def porcentajes( = {}) @vct = "#{[:vct]}" @proteinas = "#{[:proteinas]}" @grasas = "#{[:grasas]}" @hidratos = "#{[:hidratos]}" end |
#titulo(name) ⇒ Object
17 18 19 |
# File 'lib/menus/menu_dsl.rb', line 17 def titulo (name) @titulos = name end |
#to_s ⇒ Object
41 42 43 44 45 46 |
# File 'lib/menus/menu_dsl.rb', line 41 def to_s buffer = "#{@titulos} " buffer << "(#{@ingesta_porcentajes.join(' - ')}%)\n" buffer << "- #{@platos.join("\n- ")}\n" buffer << "V.C.T. | % #{@vct} kcal | #{@proteinas}% - #{@grasas}% - #{@hidratos}%\n" end |