Class: MenuDSL
- Inherits:
-
Object
- Object
- MenuDSL
- Defined in:
- lib/prct6/dieta.rb
Instance Attribute Summary collapse
-
#ingesta ⇒ Object
Returns the value of attribute ingesta.
-
#nombre ⇒ Object
Returns the value of attribute nombre.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#porcentajes ⇒ Object
Returns the value of attribute porcentajes.
-
#titulo ⇒ Object
Returns the value of attribute titulo.
Instance Method Summary collapse
- #ingest(options = {}) ⇒ Object
-
#initialize(nombre, &block) ⇒ MenuDSL
constructor
A new instance of MenuDSL.
- #plato(options = {}) ⇒ Object
- #porcent(options = {}) ⇒ Object
- #title(name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(nombre, &block) ⇒ MenuDSL
Returns a new instance of MenuDSL.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/prct6/dieta.rb', line 6 def initialize(nombre, &block) self.nombre = nombre self.titulo = "" self.ingesta = [] self.platos = [] self.porcentajes = [] if block_given? if block.arity == 1 yield self else instance_eval &block end end end |
Instance Attribute Details
#ingesta ⇒ Object
Returns the value of attribute ingesta.
4 5 6 |
# File 'lib/prct6/dieta.rb', line 4 def ingesta @ingesta end |
#nombre ⇒ Object
Returns the value of attribute nombre.
4 5 6 |
# File 'lib/prct6/dieta.rb', line 4 def nombre @nombre end |
#platos ⇒ Object
Returns the value of attribute platos.
4 5 6 |
# File 'lib/prct6/dieta.rb', line 4 def platos @platos end |
#porcentajes ⇒ Object
Returns the value of attribute porcentajes.
4 5 6 |
# File 'lib/prct6/dieta.rb', line 4 def porcentajes @porcentajes end |
#titulo ⇒ Object
Returns the value of attribute titulo.
4 5 6 |
# File 'lib/prct6/dieta.rb', line 4 def titulo @titulo end |
Instance Method Details
#ingest(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/prct6/dieta.rb', line 27 def ingest( = {}) ing = [] if ([:min] && [:max]) ing << [:min] ing << [:max] else ing << [:max] end ingesta << ing end |
#plato(options = {}) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/prct6/dieta.rb', line 41 def plato( = {}) dish = [] dish << "#{[:descripcion]}" dish << "#{[:porcion]}" dish << "#{[:gramos]}" platos << dish end |
#porcent(options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/prct6/dieta.rb', line 50 def porcent( = {}) por = [] por << "#{[:vct]}" por << "#{[:proteinas]}" por << "#{[:grasas]}" por << "#{[:hidratos]}" porcentajes << por end |
#title(name) ⇒ Object
22 23 24 25 |
# File 'lib/prct6/dieta.rb', line 22 def title(name) aux = name titulo << aux end |
#to_s ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/prct6/dieta.rb', line 61 def to_s output = nombre output << "\n#{'=' * nombre.size}\n\n" output << "#{titulo} " ingesta.each do |ing| output << "#{ing}\n" end platos.each do |dish| output << "- #{dish[0]}, #{dish[1]}, #{dish[2]}g\n" end porcentajes.each do |por| output << "V.C.T. | % #{por[0]} kcal | #{por[1]}% - #{por[2]}% - #{por[3]}%\n" end output end |