Class: Menu_dsl
- Inherits:
-
Object
- Object
- Menu_dsl
- Defined in:
- lib/prct11/menu_dsl.rb
Instance Attribute Summary collapse
-
#etiqueta ⇒ Object
Returns the value of attribute etiqueta.
-
#ingesta ⇒ Object
Returns the value of attribute ingesta.
-
#plato ⇒ Object
Returns the value of attribute plato.
-
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
-
#titulo ⇒ Object
Returns the value of attribute titulo.
Instance Method Summary collapse
- #ingestas(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 19 |
# File 'lib/prct11/menu_dsl.rb', line 4 def initialize(etiqueta, &block) self.etiqueta = etiqueta self.titulo = "" self.ingesta = [] self.plato = [] self.porcentaje = [] 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/prct11/menu_dsl.rb', line 2 def etiqueta @etiqueta end |
#ingesta ⇒ Object
Returns the value of attribute ingesta.
2 3 4 |
# File 'lib/prct11/menu_dsl.rb', line 2 def ingesta @ingesta end |
#plato ⇒ Object
Returns the value of attribute plato.
2 3 4 |
# File 'lib/prct11/menu_dsl.rb', line 2 def plato @plato end |
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
2 3 4 |
# File 'lib/prct11/menu_dsl.rb', line 2 def porcentaje @porcentaje end |
#titulo ⇒ Object
Returns the value of attribute titulo.
2 3 4 |
# File 'lib/prct11/menu_dsl.rb', line 2 def titulo @titulo end |
Instance Method Details
#ingestas(options = {}) ⇒ Object
26 27 28 29 |
# File 'lib/prct11/menu_dsl.rb', line 26 def ingestas( = {}) ingesta << "#{[:max]}" if [:max] ingesta << "#{[:min]}" if [:min] end |
#platos(options = {}) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/prct11/menu_dsl.rb', line 31 def platos( = {}) pl = [] pl << "#{[:descPlato]}" if [:descPlato] pl << "#{[:descPorcion]}" if [:descPorcion] pl << "#{[:ingestaGramos]}" if [:ingestaGramos] plato << pl end |
#porcentajes(options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/prct11/menu_dsl.rb', line 40 def porcentajes( = {}) pc = [] pc << "#{[:vct]}" if [:vct] pc << "#{[:proteinas]}" if [:proteinas] pc << "#{[:grasas]}" if [:grasas] pc << "#{[:hidratos]}" if [:hidratos] porcentaje << pc end |
#titulos(options = {}) ⇒ Object
22 23 24 |
# File 'lib/prct11/menu_dsl.rb', line 22 def titulos( = {}) titulo << "#{[:titulo]}" end |
#to_s ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/prct11/menu_dsl.rb', line 50 def to_s output = etiqueta output << "\n#{'=' * etiqueta.size}\n\n" output << "#{titulo}" output << "(#{ingesta[0]} - #{ingesta[1]}%) \n" plato.each_with_index do |plato, index| output << "- #{plato[0]}, #{plato[1]}, #{plato[2]}g\n" end porcentaje.each_with_index do |porcentaje, index| output << "V.C.T. | % #{porcentaje[0]}Kcal | #{porcentaje[1]}% - #{porcentaje[2]}% - #{porcentaje[3]}%\n" end output end |