Class: PlatoDSL
- Inherits:
-
Object
- Object
- PlatoDSL
- Defined in:
- lib/nutriente/platoDSL.rb
Instance Attribute Summary collapse
-
#ingredientes ⇒ Object
Returns the value of attribute ingredientes.
-
#nombre ⇒ Object
Returns the value of attribute nombre.
-
#va ⇒ Object
Returns the value of attribute va.
-
#vn ⇒ Object
Returns the value of attribute vn.
Instance Method Summary collapse
- #ingrediente(nombre, opcion = {}) ⇒ Object
-
#initialize(nombre, vn, va, &block) ⇒ PlatoDSL
constructor
A new instance of PlatoDSL.
- #to_s ⇒ Object
Constructor Details
#initialize(nombre, vn, va, &block) ⇒ PlatoDSL
Returns a new instance of PlatoDSL.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nutriente/platoDSL.rb', line 5 def initialize(nombre, vn, va, &block) @nombre = nombre @vn = vn @va = va @ingredientes = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#ingredientes ⇒ Object
Returns the value of attribute ingredientes.
3 4 5 |
# File 'lib/nutriente/platoDSL.rb', line 3 def ingredientes @ingredientes end |
#nombre ⇒ Object
Returns the value of attribute nombre.
3 4 5 |
# File 'lib/nutriente/platoDSL.rb', line 3 def nombre @nombre end |
#va ⇒ Object
Returns the value of attribute va.
3 4 5 |
# File 'lib/nutriente/platoDSL.rb', line 3 def va @va end |
#vn ⇒ Object
Returns the value of attribute vn.
3 4 5 |
# File 'lib/nutriente/platoDSL.rb', line 3 def vn @vn end |
Instance Method Details
#ingrediente(nombre, opcion = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/nutriente/platoDSL.rb', line 28 def ingrediente(nombre, opcion = {}) ingrediente = nombre ingrediente << " (#{opcion[:gramos]})" if opcion[:gramos] @vn = " (#{opcion[:vn]})" if opcion[:vn] @va = " (#{opcion[:va]})" if opcion[:va] @ingredientes << ingrediente end |
#to_s ⇒ Object
21 22 23 24 25 |
# File 'lib/nutriente/platoDSL.rb', line 21 def to_s output = @nombre output << " | Valor Nutricional: #{@vn} | Valor Ambiental: #{@va} | Ingredientes: #{@ingredientes.join(', ')}\n" output end |