Class: Comida::Plato_bloque
- Inherits:
-
Object
- Object
- Comida::Plato_bloque
- Defined in:
- lib/comida/palto_bloque.rb
Instance Attribute Summary collapse
-
#alimentos ⇒ Object
readonly
Returns the value of attribute alimentos.
-
#descripcion(descrip) ⇒ Object
readonly
Returns the value of attribute descripcion.
-
#nombre ⇒ Object
readonly
Returns the value of attribute nombre.
Instance Method Summary collapse
- #alimento(descripcion, options = {}) ⇒ Object
-
#initialize(name, &block) ⇒ Plato_bloque
constructor
A new instance of Plato_bloque.
- #to_s ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Plato_bloque
Returns a new instance of Plato_bloque.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/comida/palto_bloque.rb', line 22 def initialize(name, &block) @nombre = name @alimentos = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#alimentos ⇒ Object (readonly)
Returns the value of attribute alimentos.
20 21 22 |
# File 'lib/comida/palto_bloque.rb', line 20 def alimentos @alimentos end |
#descripcion(descrip) ⇒ Object (readonly)
Returns the value of attribute descripcion.
20 21 22 |
# File 'lib/comida/palto_bloque.rb', line 20 def descripcion @descripcion end |
#nombre ⇒ Object (readonly)
Returns the value of attribute nombre.
20 21 22 |
# File 'lib/comida/palto_bloque.rb', line 20 def nombre @nombre end |
Instance Method Details
#alimento(descripcion, options = {}) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/comida/palto_bloque.rb', line 39 def alimento(descripcion, = {}) descripcion << "(#{[:description]})" if [:description] descripcion << "(#{[:gramos]})" if [:gramos] @alimentos << descripcion end |
#to_s ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/comida/palto_bloque.rb', line 46 def to_s output = @nombre output << "\n#{'=' * @nombre.size}\n\n" output << "Platos : \n\n" @alimentos.each_with_index do |alimento, index| output << "#{index + 1}) #{alimento[:descripcion]}, #{alimento[:gramos]}\n" end output end |