class Alimento::MenuDSL
Attributes
nombre[R]
precio_total[R]
precios[R]
Public Class Methods
new(nombre) { |self| ... }
click to toggle source
# File lib/alimento/menuDSL.rb, line 7 def initialize(nombre, &block) @nombre = nombre @componentes_menu = [] @precios = [] @descripcion_menu = "" @precio_total if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end
Public Instance Methods
componente(options = {})
click to toggle source
# File lib/alimento/menuDSL.rb, line 29 def componente(options = {}) @componentes_menu << options[:platito] if options[:platito] @precios << options[:precio] if options[:precio] end
descripcion(descr)
click to toggle source
# File lib/alimento/menuDSL.rb, line 24 def descripcion(descr) @descripcion_menu = descr end
precio(coste)
click to toggle source
# File lib/alimento/menuDSL.rb, line 35 def precio(coste) @precio_total = coste end
to_s()
click to toggle source
# File lib/alimento/menuDSL.rb, line 40 def to_s output = "Nombre de menu: #{@nombre}" output += "\nPlatos:" @componentes_menu.each {|iter| if iter.platito == nil iter.platillo() end output += "\n\n\tTipo: #{iter.platito.nombre}" output += "\n\tValor Nutricional: #{iter.platito.VCT()}" output += "\n\tValor Ambiental: #{iter.platito.emisiones_total()}" } output += "\n\nPrecio menĂº: #{@precio_total}" output end