Class: PlatoDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/nutriente/platoDSL.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nombre, vn, va, &block) ⇒ PlatoDSL

Returns a new instance of PlatoDSL.



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

def initialize(nombre, vn, va, &block)

	@nombre = nombre
	@vn = vn
	@va = va
	@ingredientes = []
	
	if block_given?  
		if block.arity == 1
			yield self
		else
			instance_eval(&block) 
		end
	end
end

Instance Attribute Details

#ingredientesObject

Returns the value of attribute ingredientes.



3
4
5
# File 'lib/nutriente/platoDSL.rb', line 3

def ingredientes
  @ingredientes
end

#nombreObject

Returns the value of attribute nombre.



3
4
5
# File 'lib/nutriente/platoDSL.rb', line 3

def nombre
  @nombre
end

#vaObject

Returns the value of attribute va.



3
4
5
# File 'lib/nutriente/platoDSL.rb', line 3

def va
  @va
end

#vnObject

Returns the value of attribute vn.



3
4
5
# File 'lib/nutriente/platoDSL.rb', line 3

def vn
  @vn
end

Instance Method Details

#ingrediente(nombre, opcion = {}) ⇒ Object



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

def ingrediente(nombre, opcion = {})
	ingrediente = nombre
	ingrediente << " (#{opcion[:gramos]})" if opcion[:gramos]
	@vn = " (#{opcion[:vn]})" if opcion[:vn]
	@va = " (#{opcion[:va]})" if opcion[:va]
	@ingredientes << ingrediente
end

#to_sObject



21
22
23
24
25
# File 'lib/nutriente/platoDSL.rb', line 21

def to_s
	output = @nombre
	output << " | Valor Nutricional: #{@vn} | Valor Ambiental: #{@va} | Ingredientes: #{@ingredientes.join(', ')}\n"
	output
end