Class: MenuDSL

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

Instance Method Summary collapse

Constructor Details

#initialize(nombre, &block) ⇒ MenuDSL

Returns a new instance of MenuDSL.



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/FoodImpact/menu.rb', line 44

def initialize(nombre, &block)
  @name = nombre
  @description = ""
  @foods = []
  @price = ""
  if block_given?
    if block.arity == 1
      yield self
    else
      instance_eval(&block)
    end
  end
end

Instance Method Details

#componente(price, &block) ⇒ Object



66
67
68
69
70
71
# File 'lib/FoodImpact/menu.rb', line 66

def componente (price, &block)
  plato = PlatoDSL.new(&block)
  plato = plato.to_s
  plato << " #{price}"
  @foods << plato
end

#descripcion(desc) ⇒ Object



62
63
64
# File 'lib/FoodImpact/menu.rb', line 62

def descripcion(desc)
  description = desc
end

#precio(pre) ⇒ Object



58
59
60
# File 'lib/FoodImpact/menu.rb', line 58

def precio(pre)
  @price = pre
end

#to_sObject



73
74
75
76
77
# File 'lib/FoodImpact/menu.rb', line 73

def to_s
  out = ""
  @foods.each { |x| out << "#{x}, " }
  out
end