Class: MenuDSL
- Inherits:
-
Object
- Object
- MenuDSL
- Defined in:
- lib/nutriente/menuDSL.rb
Instance Attribute Summary collapse
-
#nombre ⇒ Object
Returns the value of attribute nombre.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#precio ⇒ Object
Returns the value of attribute precio.
Instance Method Summary collapse
-
#initialize(nombre, precio, &block) ⇒ MenuDSL
constructor
A new instance of MenuDSL.
- #plato(p, opcion = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(nombre, precio, &block) ⇒ MenuDSL
Returns a new instance of MenuDSL.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/nutriente/menuDSL.rb', line 5 def initialize(nombre, precio, &block) @nombre = nombre @precio = precio @platos = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#nombre ⇒ Object
Returns the value of attribute nombre.
3 4 5 |
# File 'lib/nutriente/menuDSL.rb', line 3 def nombre @nombre end |
#platos ⇒ Object
Returns the value of attribute platos.
3 4 5 |
# File 'lib/nutriente/menuDSL.rb', line 3 def platos @platos end |
#precio ⇒ Object
Returns the value of attribute precio.
3 4 5 |
# File 'lib/nutriente/menuDSL.rb', line 3 def precio @precio end |
Instance Method Details
#plato(p, opcion = {}) ⇒ Object
28 29 30 |
# File 'lib/nutriente/menuDSL.rb', line 28 def plato(p, opcion = {}) @platos << p end |
#to_s ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/nutriente/menuDSL.rb', line 19 def to_s output = @nombre output << " #{@precio}€" output << "\n#{'-' * @nombre.size}\n" #output << "#{puts @platos}\n" output end |