Class: Menu_dsl
- Inherits:
-
Object
- Object
- Menu_dsl
- Defined in:
- lib/prct08/menu_dsl.rb
Instance Attribute Summary collapse
-
#etiqueta ⇒ Object
Returns the value of attribute etiqueta.
-
#ingestaIn ⇒ Object
Returns the value of attribute ingestaIn.
-
#platosIn ⇒ Object
Returns the value of attribute platosIn.
-
#porcentajeIn ⇒ Object
Returns the value of attribute porcentajeIn.
-
#titulo ⇒ Object
Returns the value of attribute titulo.
Instance Method Summary collapse
- #ingesta(options = {}) ⇒ Object
-
#initialize(etiqueta, &block) ⇒ Menu_dsl
constructor
A new instance of Menu_dsl.
- #platos(options = {}) ⇒ Object
- #porcentajes(options = {}) ⇒ Object
- #titulos(options = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(etiqueta, &block) ⇒ Menu_dsl
Returns a new instance of Menu_dsl.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/prct08/menu_dsl.rb', line 4 def initialize(etiqueta, &block) self.etiqueta = etiqueta self.titulo = "" self.ingestaIn = [] self.platosIn = [] self.porcentajeIn = [] 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/prct08/menu_dsl.rb', line 2 def etiqueta @etiqueta end |
#ingestaIn ⇒ Object
Returns the value of attribute ingestaIn.
2 3 4 |
# File 'lib/prct08/menu_dsl.rb', line 2 def ingestaIn @ingestaIn end |
#platosIn ⇒ Object
Returns the value of attribute platosIn.
2 3 4 |
# File 'lib/prct08/menu_dsl.rb', line 2 def platosIn @platosIn end |
#porcentajeIn ⇒ Object
Returns the value of attribute porcentajeIn.
2 3 4 |
# File 'lib/prct08/menu_dsl.rb', line 2 def porcentajeIn @porcentajeIn end |
#titulo ⇒ Object
Returns the value of attribute titulo.
2 3 4 |
# File 'lib/prct08/menu_dsl.rb', line 2 def titulo @titulo end |
Instance Method Details
#ingesta(options = {}) ⇒ Object
24 25 26 27 |
# File 'lib/prct08/menu_dsl.rb', line 24 def ingesta( = {}) ingestaIn << "#{[:min]}" if [:min] ingestaIn << "#{[:max]}" if [:max] end |
#platos(options = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/prct08/menu_dsl.rb', line 29 def platos( = {}) plato = [] plato << "#{[:descripcion]}" if [:descripcion] plato << "#{[:porcion]}" if [:porcion] plato << "#{[:gramos]}" if [:gramos] platosIn << plato end |
#porcentajes(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/prct08/menu_dsl.rb', line 37 def porcentajes( = {}) porcentaje = [] porcentaje << "#{[:vct]}" if [:vct] porcentaje << "#{[:proteinas]}" if [:proteinas] porcentaje << "#{[:grasas]}" if [:grasas] porcentaje << "#{[:hidratos]}" if [:hidratos] porcentajeIn << porcentaje end |
#titulos(options = {}) ⇒ Object
20 21 22 |
# File 'lib/prct08/menu_dsl.rb', line 20 def titulos( = {}) titulo << "#{[:titulo]}" end |
#to_s ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/prct08/menu_dsl.rb', line 46 def to_s out = "#{titulo}" out << "\nMinima: #{ingestaIn[0]} % - Maximo: #{ingestaIn[1]} %" platosIn.each_with_index do |plato, index| out << "\n\tDescripcion: #{plato[0]} \n\tPorcion: #{plato[1]} \n\tGramos: #{plato[2]}\n" end porcentajeIn.each_with_index do |porcentaje, index| out << "\n\tV.C.T: #{porcentaje[0]} \n\tProteinas: #{porcentaje[1]} \n\tGrasas: #{porcentaje[2]} \n\tHidratos:#{porcentaje[3]} \n" end out end |