Class: Comida::Menu
- Inherits:
-
Object
- Object
- Comida::Menu
- Defined in:
- lib/comida/menu.rb
Instance Attribute Summary collapse
-
#descripcion(descrip) ⇒ Object
readonly
Returns the value of attribute descripcion.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
-
#platos ⇒ Object
readonly
Returns the value of attribute platos.
-
#precio_total(precio) ⇒ Object
readonly
Returns the value of attribute precio_total.
-
#precios ⇒ Object
readonly
Returns the value of attribute precios.
-
#v_ambiental ⇒ Object
readonly
Returns the value of attribute v_ambiental.
-
#v_nutricional ⇒ Object
readonly
Returns the value of attribute v_nutricional.
Instance Method Summary collapse
-
#initialize(nombre, &block) ⇒ Menu
constructor
A new instance of Menu.
- #plato(nombre, options = {}) ⇒ Object
- #preparacion(descripcion, options = {}) ⇒ Object
- #to_s ⇒ Object
- #valor_ambiental(valor) ⇒ Object
- #valor_nutricional(valor) ⇒ Object
Constructor Details
#initialize(nombre, &block) ⇒ Menu
Returns a new instance of Menu.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/comida/menu.rb', line 22 def initialize(nombre, &block) @nombre = nombre @platos = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#descripcion(descrip) ⇒ Object (readonly)
Returns the value of attribute descripcion.
20 21 22 |
# File 'lib/comida/menu.rb', line 20 def descripcion @descripcion end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
20 21 22 |
# File 'lib/comida/menu.rb', line 20 def nombre @nombre end |
#platos ⇒ Object (readonly)
Returns the value of attribute platos.
20 21 22 |
# File 'lib/comida/menu.rb', line 20 def platos @platos end |
#precio_total(precio) ⇒ Object (readonly)
Returns the value of attribute precio_total.
20 21 22 |
# File 'lib/comida/menu.rb', line 20 def precio_total @precio_total end |
#precios ⇒ Object (readonly)
Returns the value of attribute precios.
20 21 22 |
# File 'lib/comida/menu.rb', line 20 def precios @precios end |
#v_ambiental ⇒ Object (readonly)
Returns the value of attribute v_ambiental.
20 21 22 |
# File 'lib/comida/menu.rb', line 20 def v_ambiental @v_ambiental end |
#v_nutricional ⇒ Object (readonly)
Returns the value of attribute v_nutricional.
20 21 22 |
# File 'lib/comida/menu.rb', line 20 def v_nutricional @v_nutricional end |
Instance Method Details
#plato(nombre, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/comida/menu.rb', line 39 def plato(nombre, = {}) plato = nombre plato << "(#{[:descripcion]})" if [:descripcion] plato << "(#{[:cantidad]})" if [:cantidad] plato << "(#{[:precio]})" if [:precio] @platos << plato end |
#preparacion(descripcion, options = {}) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/comida/menu.rb', line 48 def preparacion(descripcion, = {}) preparar = descripcion preparar << "(#{[:duracion]})" if [:duracion] @platos << preparar end |
#to_s ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/comida/menu.rb', line 67 def to_s output = @nombre output << "\n#{'=' * @nombre.size}\n\n" output << "Platos : \n\n" @platos.each_with_index do |plato, index| output << "#{index + 1}) #{plato[:descripcion]}, #{plato[:cantidad]}, #{plato[:precio]}\n" end output end |
#valor_ambiental(valor) ⇒ Object
63 64 65 |
# File 'lib/comida/menu.rb', line 63 def valor_ambiental(valor) @v_ambiental = valor end |
#valor_nutricional(valor) ⇒ Object
59 60 61 |
# File 'lib/comida/menu.rb', line 59 def valor_nutricional(valor) @v_nutricional = valor end |