Class: Plate

Inherits:
Object
  • Object
show all
Defined in:
lib/plate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_sObject



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