Class: MenuProc

Inherits:
Dieta show all
Defined in:
lib/menu/Menu_Proc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Dieta

#<=>, #==, #setPlato

Constructor Details

#initialize(titulo, &bloque) ⇒ MenuProc

Returns a new instance of MenuProc.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/menu/Menu_Proc.rb', line 4

def initialize(titulo, &bloque) 
    self.titulos = ""
    self.vct = []
    self.ingestas = []
    self.proteinas = []
    self.grasas = []
    self.hidratos = []
    self.platos = []
    
    if block_given?  
        if bloque.arity == 1
            yield self
        else
            instance_eval(&bloque) 
        end
    end
end

Instance Attribute Details

#grasasObject

Returns the value of attribute grasas.



3
4
5
# File 'lib/menu/Menu_Proc.rb', line 3

def grasas
  @grasas
end

#hidratosObject

Returns the value of attribute hidratos.



3
4
5
# File 'lib/menu/Menu_Proc.rb', line 3

def hidratos
  @hidratos
end

#ingestasObject

Returns the value of attribute ingestas.



3
4
5
# File 'lib/menu/Menu_Proc.rb', line 3

def ingestas
  @ingestas
end

#platosObject

Returns the value of attribute platos.



3
4
5
# File 'lib/menu/Menu_Proc.rb', line 3

def platos
  @platos
end

#proteinasObject

Returns the value of attribute proteinas.



3
4
5
# File 'lib/menu/Menu_Proc.rb', line 3

def proteinas
  @proteinas
end

#titulosObject

Returns the value of attribute titulos.



3
4
5
# File 'lib/menu/Menu_Proc.rb', line 3

def titulos
  @titulos
end

#vctObject

Returns the value of attribute vct.



3
4
5
# File 'lib/menu/Menu_Proc.rb', line 3

def vct
  @vct
end

Instance Method Details

#ingesta(options = {}) ⇒ Object



26
27
28
29
# File 'lib/menu/Menu_Proc.rb', line 26

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

#plato(options = {}) ⇒ Object



31
32
33
34
35
36
# File 'lib/menu/Menu_Proc.rb', line 31

def plato(options = {})
    desc = "#{options[:descripcion]}" if options[:descripcion]
    porc = "#{options[:porcion]}" if options[:porcion]
    gra = options[:gramos] if options[:gramos]
    self.platos << Plato.new(desc, porc, gra)
end

#porcentajes(options = {}) ⇒ Object



37
38
39
40
41
42
# File 'lib/menu/Menu_Proc.rb', line 37

def porcentajes(options = {})
   self.vct = options[:vct] if options[:vct] 
   self.proteinas = options[:proteinas] if options[:proteinas]
   self.grasas = options[:grasas] if options[:grasas]
   self.hidratos = options[:hidratos] if options[:hidratos]
end

#titulo(options = {}) ⇒ Object



22
23
24
# File 'lib/menu/Menu_Proc.rb', line 22

def titulo(options = {})
   self.titulos = "#{options[:name]}" if options[:name] 
end

#to_sObject



43
44
45
46
47
48
49
# File 'lib/menu/Menu_Proc.rb', line 43

def to_s
    s = "#{titulos} (#{ingestas[0]}% - #{ingestas[1]}%)\n"
    platos.each_with_index do |comida|
        s << "- #{comida.descripcion}, #{comida.porcion}, #{comida.gramos} g\n" 
    end
    s << "V.C.T. | % #{vct} kcal | #{proteinas}% - #{grasas}% - #{hidratos}%"
end