Class: Plate
- Inherits:
-
Object
- Object
- Plate
- Defined in:
- lib/plate.rb
Instance Attribute Summary collapse
-
#alimento(options = {}) ⇒ Object
Returns the value of attribute alimento.
-
#nombre(name, options = {}) ⇒ Object
Returns the value of attribute nombre.
Instance Method Summary collapse
-
#initialize(name, &block) ⇒ Plate
constructor
A new instance of Plate.
- #to_s ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Plate
Returns a new instance of Plate.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/plate.rb', line 4 def initialize(name, &block) @nombre = name @alimento = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#alimento(options = {}) ⇒ Object
Returns the value of attribute alimento.
2 3 4 |
# File 'lib/plate.rb', line 2 def alimento @alimento end |
#nombre(name, options = {}) ⇒ Object
Returns the value of attribute nombre.
2 3 4 |
# File 'lib/plate.rb', line 2 def nombre @nombre end |
Instance Method Details
#to_s ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/plate.rb', line 17 def to_s output = @nombre output << "\n#{'=' * @nombre.size}\n\n" output << "Alimentos: #{@alimento.join(', ')}\n\n" output end |