Class: Menu_DSL

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(titulos, &block) ⇒ Menu_DSL

Returns a new instance of Menu_DSL.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/menus/menu_dsl.rb', line 4

def initialize(titulos, &block)
    self.titulos = titulos
    self.platos = []

    if block_given?  
      if block.arity == 1
        yield self
      else
       instance_eval(&block) 
      end
    end
end

Instance Attribute Details

#descripcionObject

Returns the value of attribute descripcion.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def descripcion
  @descripcion
end

#gramosObject

Returns the value of attribute gramos.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def gramos
  @gramos
end

#grasasObject

Returns the value of attribute grasas.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def grasas
  @grasas
end

#hidratosObject

Returns the value of attribute hidratos.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def hidratos
  @hidratos
end

#ingesta_porcentajesObject

Returns the value of attribute ingesta_porcentajes.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def ingesta_porcentajes
  @ingesta_porcentajes
end

#platosObject

Returns the value of attribute platos.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def platos
  @platos
end

#porcionObject

Returns the value of attribute porcion.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def porcion
  @porcion
end

#proteinasObject

Returns the value of attribute proteinas.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def proteinas
  @proteinas
end

#titulosObject

Returns the value of attribute titulos.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def titulos
  @titulos
end

#vctObject

Returns the value of attribute vct.



2
3
4
# File 'lib/menus/menu_dsl.rb', line 2

def vct
  @vct
end

Instance Method Details

#ingesta(options = {}) ⇒ Object



21
22
23
24
25
26
# File 'lib/menus/menu_dsl.rb', line 21

def ingesta(options = {})
    min_max = []
    min_max << "#{options[:min]}"
    min_max << "#{options[:max]}"
    @ingesta_porcentajes = min_max
end

#plato(options = {}) ⇒ Object



28
29
30
31
32
# File 'lib/menus/menu_dsl.rb', line 28

def plato(options = {})
    ingredientes = []
    ingredientes << "#{options[:descripcion]}, #{options[:porcion]}, #{options[:gramos]}"
    @platos.push(ingredientes)
end

#porcentajes(options = {}) ⇒ Object



34
35
36
37
38
39
# File 'lib/menus/menu_dsl.rb', line 34

def porcentajes(options = {})
    @vct = "#{options[:vct]}"
    @proteinas = "#{options[:proteinas]}"
    @grasas = "#{options[:grasas]}"
    @hidratos = "#{options[:hidratos]}"
end

#titulo(name) ⇒ Object



17
18
19
# File 'lib/menus/menu_dsl.rb', line 17

def titulo (name)
    @titulos = name
end

#to_sObject



41
42
43
44
45
46
# File 'lib/menus/menu_dsl.rb', line 41

def to_s
    buffer = "#{@titulos} "
    buffer << "(#{@ingesta_porcentajes.join(' - ')}%)\n"
    buffer << "- #{@platos.join("\n- ")}\n"
    buffer << "V.C.T. | % #{@vct} kcal | #{@proteinas}% - #{@grasas}% - #{@hidratos}%\n"
end