Class: MenuDS

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ MenuDS

Returns a new instance of MenuDS



20
21
22
23
24
25
26
27
# File 'lib/dieta/menu.rb', line 20

def initialize(&block)
	@titulos
	@ingesta = []
	@plato = []
	@porcentaje = []

	instance_eval(&block)
end

Instance Attribute Details

#ingestaObject

Returns the value of attribute ingesta



18
19
20
# File 'lib/dieta/menu.rb', line 18

def ingesta
  @ingesta
end

#platoObject

Returns the value of attribute plato



18
19
20
# File 'lib/dieta/menu.rb', line 18

def plato
  @plato
end

#porcentajeObject

Returns the value of attribute porcentaje



18
19
20
# File 'lib/dieta/menu.rb', line 18

def porcentaje
  @porcentaje
end

#tituloObject

Returns the value of attribute titulo



18
19
20
# File 'lib/dieta/menu.rb', line 18

def titulo
  @titulo
end

Instance Method Details

#ingestas(options = {}) ⇒ Object



33
34
35
# File 'lib/dieta/menu.rb', line 33

def ingestas(options = {})
	@ingesta << " (#{options[:max]} - #{options[:min]}) " if options[:max] && options[:min]
end

#platos(options = {}) ⇒ Object



37
38
39
# File 'lib/dieta/menu.rb', line 37

def platos(options = {})
	@plato << " (#{options[:descripcion]} #{options[:porcion]} #{options[:gramos]} " if options[:descripcion] && options[:porcion] && options[:gramos]
end

#porcentajes(options = {}) ⇒ Object



41
42
43
# File 'lib/dieta/menu.rb', line 41

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

#titulos(titulo) ⇒ Object



29
30
31
# File 'lib/dieta/menu.rb', line 29

def titulos(titulo)
	@titulo = titulo
end

#to_sObject



45
46
47
48
49
50
51
52
# File 'lib/dieta/menu.rb', line 45

def to_s
	s = ""
	s << "#{titulo} #{ingesta})\n"
	for i in 0..plato.length-1
		s << "- #{plato[i]}\n"
	end
	s << "V.C.T. | % \t#{porcentaje}\n"
end