Class: MenuDSL
- Inherits:
-
Object
- Object
- MenuDSL
- Defined in:
- lib/menudietetico/menu.rb
Instance Attribute Summary collapse
-
#grasas ⇒ Object
Returns the value of attribute grasas.
-
#hidratos ⇒ Object
Returns the value of attribute hidratos.
-
#platos ⇒ Object
Returns the value of attribute platos.
-
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
-
#porcion ⇒ Object
Returns the value of attribute porcion.
-
#proteinas ⇒ Object
Returns the value of attribute proteinas.
-
#titulo ⇒ Object
Returns the value of attribute titulo.
-
#vct ⇒ Object
Returns the value of attribute vct.
Instance Method Summary collapse
- #getPlatos ⇒ Object
- #in_platos(options = {}) ⇒ Object
- #ingesta(options = {}) ⇒ Object
-
#initialize(name, &block) ⇒ MenuDSL
constructor
A new instance of MenuDSL.
- #porcentajes(options = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ MenuDSL
Returns a new instance of MenuDSL.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/menudietetico/menu.rb', line 140 def initialize(name, &block) @titulo = name @porcentaje @platos = [] @porcion @vct @proteinas @grasas @hidratos @ingesta if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#grasas ⇒ Object
Returns the value of attribute grasas.
137 138 139 |
# File 'lib/menudietetico/menu.rb', line 137 def grasas @grasas end |
#hidratos ⇒ Object
Returns the value of attribute hidratos.
138 139 140 |
# File 'lib/menudietetico/menu.rb', line 138 def hidratos @hidratos end |
#platos ⇒ Object
Returns the value of attribute platos.
133 134 135 |
# File 'lib/menudietetico/menu.rb', line 133 def platos @platos end |
#porcentaje ⇒ Object
Returns the value of attribute porcentaje.
132 133 134 |
# File 'lib/menudietetico/menu.rb', line 132 def porcentaje @porcentaje end |
#porcion ⇒ Object
Returns the value of attribute porcion.
134 135 136 |
# File 'lib/menudietetico/menu.rb', line 134 def porcion @porcion end |
#proteinas ⇒ Object
Returns the value of attribute proteinas.
136 137 138 |
# File 'lib/menudietetico/menu.rb', line 136 def proteinas @proteinas end |
#titulo ⇒ Object
Returns the value of attribute titulo.
131 132 133 |
# File 'lib/menudietetico/menu.rb', line 131 def titulo @titulo end |
#vct ⇒ Object
Returns the value of attribute vct.
135 136 137 |
# File 'lib/menudietetico/menu.rb', line 135 def vct @vct end |
Instance Method Details
#getPlatos ⇒ Object
185 186 187 |
# File 'lib/menudietetico/menu.rb', line 185 def getPlatos @platos.join(" ") end |
#in_platos(options = {}) ⇒ Object
161 162 163 164 165 166 167 168 |
# File 'lib/menudietetico/menu.rb', line 161 def in_platos( = {}) plato = [] plato << "#{[:descripcion]}" if [:descripcion] plato << "#{[:porcion]}" if [:porcion] plato << "#{[:gramos]}" if [:gramos] #@platos = plato @platos.push(plato) end |
#ingesta(options = {}) ⇒ Object
177 178 179 180 181 182 183 |
# File 'lib/menudietetico/menu.rb', line 177 def ingesta( = {}) porcentaje = [] porcentaje << "#{[:min]}" if [:min] porcentaje << "#{[:max]}" if [:max] @porcentaje = porcentaje end |
#porcentajes(options = {}) ⇒ Object
170 171 172 173 174 175 |
# File 'lib/menudietetico/menu.rb', line 170 def porcentajes( = {}) @vct = "#{[:vct]}" if [:vct] @proteinas = "#{[:proteinas]}" if [:proteinas] @grasas = "#{[:grasas]}" if [:grasas] @hidratos = "#{[:hidratos]}" if [:hidratos] end |
#to_s ⇒ Object
189 190 191 |
# File 'lib/menudietetico/menu.rb', line 189 def to_s return "#{@titulo} " + "(#{@porcentaje[0]} - #{@porcentaje[1]})\n" + getPlatos + "\n" + "V.C.T. | % #{@vct} kcal | #{@proteinas}% - #{@grasas}% - #{@hidratos}%\n" end |