Class: MenuDSL

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(etiqueta, &block) ⇒ MenuDSL

Returns a new instance of MenuDSL.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/prct7/menuDSL.rb', line 4

def initialize(etiqueta, &block)
    @etiqueta_ = etiqueta
    @titulo_ = ""
    @ingesta_ = []
    @platos_ = []
    @porcentajes_ = []
    if block_given?
        if block.arity == 1
            yield self
        else
            instance_eval(&block)
        end
    end
end

Instance Attribute Details

#etiqueta_Object

Returns the value of attribute etiqueta_.



2
3
4
# File 'lib/prct7/menuDSL.rb', line 2

def etiqueta_
  @etiqueta_
end

#ingesta_Object

Returns the value of attribute ingesta_.



2
3
4
# File 'lib/prct7/menuDSL.rb', line 2

def ingesta_
  @ingesta_
end

#platos_Object

Returns the value of attribute platos_.



2
3
4
# File 'lib/prct7/menuDSL.rb', line 2

def platos_
  @platos_
end

#porcentajes_Object

Returns the value of attribute porcentajes_.



2
3
4
# File 'lib/prct7/menuDSL.rb', line 2

def porcentajes_
  @porcentajes_
end

#titulo_Object

Returns the value of attribute titulo_.



2
3
4
# File 'lib/prct7/menuDSL.rb', line 2

def titulo_
  @titulo_
end

Instance Method Details

#ingesta(options = {}) ⇒ Object



23
24
25
26
# File 'lib/prct7/menuDSL.rb', line 23

def ingesta(options = {})
    ingesta_ << options[:min] if options[:min]
    ingesta_ << options[:max] if options[:max]
end

#plato(options = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/prct7/menuDSL.rb', line 28

def plato(options = {})
    pl = []
    pl << "#{options[:descripcion]}" if options[:descripcion]
    pl << options[:porcion] if options[:porcion]
    pl << options[:gramos] if options[:gramos]  
    platos_ << pl 
end

#porcentaje(options = {}) ⇒ Object



36
37
38
39
40
41
# File 'lib/prct7/menuDSL.rb', line 36

def porcentaje(options = {})
    porcentajes_ << options[:vct] if options[:vct]
    porcentajes_ << options[:proteinas] if options[:proteinas]
    porcentajes_ << options[:grasas] if options[:grasas]
    porcentajes_ << options[:hidratos] if options[:hidratos]  
end

#titulo(options = {}) ⇒ Object



19
20
21
# File 'lib/prct7/menuDSL.rb', line 19

def titulo(options = {})
    titulo_ << "#{options[:titulo]}"
end