Class: Menu_DSL
- Inherits:
-
Object
- Object
- Menu_DSL
- Defined in:
- lib/menu/codigo_menu_dsl.rb
Instance Attribute Summary collapse
-
#dia ⇒ Object
Returns the value of attribute dia.
-
#gras ⇒ Object
Returns the value of attribute gras.
-
#hidr ⇒ Object
Returns the value of attribute hidr.
-
#plat ⇒ Object
Returns the value of attribute plat.
-
#porc ⇒ Object
Returns the value of attribute porc.
-
#prot ⇒ Object
Returns the value of attribute prot.
-
#titu ⇒ Object
Returns the value of attribute titu.
-
#vct ⇒ Object
Returns the value of attribute vct.
Instance Method Summary collapse
- #ingesta(options = {}) ⇒ Object
-
#initialize(dia, &block) ⇒ Menu_DSL
constructor
A new instance of Menu_DSL.
- #plato(options = {}) ⇒ Object
- #porcentajes(options = {}) ⇒ Object
- #titulo(titul) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(dia, &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 20 21 |
# File 'lib/menu/codigo_menu_dsl.rb', line 4 def initialize(dia, &block) self.dia = dia self.titu = "" self.porc = [] self.plat = [] self.vct = nil self.prot = nil self.gras = nil self.hidr = nil if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#dia ⇒ Object
Returns the value of attribute dia.
2 3 4 |
# File 'lib/menu/codigo_menu_dsl.rb', line 2 def dia @dia end |
#gras ⇒ Object
Returns the value of attribute gras.
2 3 4 |
# File 'lib/menu/codigo_menu_dsl.rb', line 2 def gras @gras end |
#hidr ⇒ Object
Returns the value of attribute hidr.
2 3 4 |
# File 'lib/menu/codigo_menu_dsl.rb', line 2 def hidr @hidr end |
#plat ⇒ Object
Returns the value of attribute plat.
2 3 4 |
# File 'lib/menu/codigo_menu_dsl.rb', line 2 def plat @plat end |
#porc ⇒ Object
Returns the value of attribute porc.
2 3 4 |
# File 'lib/menu/codigo_menu_dsl.rb', line 2 def porc @porc end |
#prot ⇒ Object
Returns the value of attribute prot.
2 3 4 |
# File 'lib/menu/codigo_menu_dsl.rb', line 2 def prot @prot end |
#titu ⇒ Object
Returns the value of attribute titu.
2 3 4 |
# File 'lib/menu/codigo_menu_dsl.rb', line 2 def titu @titu end |
#vct ⇒ Object
Returns the value of attribute vct.
2 3 4 |
# File 'lib/menu/codigo_menu_dsl.rb', line 2 def vct @vct end |
Instance Method Details
#ingesta(options = {}) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/menu/codigo_menu_dsl.rb', line 47 def ingesta ( = {}) porcentaje = [] porcentaje << [:min] if [:min] porcentaje << [:max] if [:max] porc << porcentaje end |
#plato(options = {}) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/menu/codigo_menu_dsl.rb', line 55 def plato ( = {}) platos = [] platos << [:descripcion] if [:descripcion] platos << [:porcion] if [:porcion] platos << [:gramos] if [:gramos] plat << platos end |
#porcentajes(options = {}) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/menu/codigo_menu_dsl.rb', line 64 def porcentajes ( = {}) @vct = [:kcals] if [:kcals] @prot = [:proteinas] if [:proteinas] @gras = [:grasas] if [:grasas] @hidr = [:hidratos] if [:hidratos] end |
#titulo(titul) ⇒ Object
43 44 45 |
# File 'lib/menu/codigo_menu_dsl.rb', line 43 def titulo (titul) titu << titul end |
#to_s ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/menu/codigo_menu_dsl.rb', line 23 def to_s output = "\n#{dia}" output << "\n#{'=' * dia.size}\n\n" output << "#{titu} | (#{porc.join(' - ')})%\n" plat.each_with_index do |platos| output << "- " platos.each_with_index do |plato, index| output << "#{plato}" if index+1 != platos.size output << ", " end end output << "\n" end output << "V.C.T | %\t#{vct} kcal | " output << "#{prot}% - #{gras}% - #{hidr}%" output end |