Class: Dietadsl
- Inherits:
-
Object
- Object
- Dietadsl
- Defined in:
- lib/menu/dsl.rb
Instance Attribute Summary collapse
-
#atributo ⇒ Object
Returns the value of attribute atributo.
-
#ingesta_diaria ⇒ Object
Returns the value of attribute ingesta_diaria.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#porcent ⇒ Object
Returns the value of attribute porcent.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #grupo(text) ⇒ Object
- #ingesta(options = {}) ⇒ Object
-
#initialize(&block) ⇒ Dietadsl
constructor
A new instance of Dietadsl.
- #plato(options = {}) ⇒ Object
- #porcentajes(options = {}) ⇒ Object
- #titulo(text) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(&block) ⇒ Dietadsl
Returns a new instance of Dietadsl.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/menu/dsl.rb', line 3 def initialize(&block) self.title = "" self.ingesta_diaria= [] self.porcent= [] self.platos = [] self.instructions = [] self.atributo= "" if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#atributo ⇒ Object
Returns the value of attribute atributo.
2 3 4 |
# File 'lib/menu/dsl.rb', line 2 def atributo @atributo end |
#ingesta_diaria ⇒ Object
Returns the value of attribute ingesta_diaria.
2 3 4 |
# File 'lib/menu/dsl.rb', line 2 def ingesta_diaria @ingesta_diaria end |
#instructions ⇒ Object
Returns the value of attribute instructions.
2 3 4 |
# File 'lib/menu/dsl.rb', line 2 def instructions @instructions end |
#platos ⇒ Object
Returns the value of attribute platos.
2 3 4 |
# File 'lib/menu/dsl.rb', line 2 def platos @platos end |
#porcent ⇒ Object
Returns the value of attribute porcent.
2 3 4 |
# File 'lib/menu/dsl.rb', line 2 def porcent @porcent end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/menu/dsl.rb', line 2 def title @title end |
Instance Method Details
#grupo(text) ⇒ Object
41 42 43 44 |
# File 'lib/menu/dsl.rb', line 41 def grupo (text) grupo = text atributo << grupo end |
#ingesta(options = {}) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/menu/dsl.rb', line 46 def ingesta ( = {}) ingesta = " (" ingesta << "#{[:min]} " if [:min] ingesta << "- #{[:max]}" if [:max] ingesta << "%)" ingesta_diaria << ingesta end |
#plato(options = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/menu/dsl.rb', line 54 def plato( = {}) plato = "" plato << "- #{[:descripcion]}," if [:descripcion] plato << " #{[:porcion]}," if [:porcion] plato << " #{[:gramos]} g" if [:gramos] plato << " #{[:mlitros]} ml" if [:mlitros] plato << "\n" platos << plato end |
#porcentajes(options = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/menu/dsl.rb', line 64 def porcentajes( = {}) porcentajes = "" porcentajes << "V.C.T | % #{[:vct]} kcal | " if [:vct] porcentajes << "#{[:proteinas]}% - " if [:proteinas] porcentajes << "#{[:grasas]}% - " if [:grasas] porcentajes << "#{[:hidratos]}%" if [:hidratos] porcent << porcentajes end |
#titulo(text) ⇒ Object
36 37 38 39 |
# File 'lib/menu/dsl.rb', line 36 def titulo (text) titulo = text title << titulo end |
#to_s ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/menu/dsl.rb', line 20 def to_s if atributo != "" output = atributo + "\n" else output=atributo end output << title output << " #{ingesta_diaria.join()}" #output << "\n#{'=' * titulo.size}\n\n" output << "\n#{platos.join()}" output << "#{porcent.join()}" output end |