Class: MenuDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/menudietetico/menu.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#grasasObject

Returns the value of attribute grasas.



137
138
139
# File 'lib/menudietetico/menu.rb', line 137

def grasas
  @grasas
end

#hidratosObject

Returns the value of attribute hidratos.



138
139
140
# File 'lib/menudietetico/menu.rb', line 138

def hidratos
  @hidratos
end

#platosObject

Returns the value of attribute platos.



133
134
135
# File 'lib/menudietetico/menu.rb', line 133

def platos
  @platos
end

#porcentajeObject

Returns the value of attribute porcentaje.



132
133
134
# File 'lib/menudietetico/menu.rb', line 132

def porcentaje
  @porcentaje
end

#porcionObject

Returns the value of attribute porcion.



134
135
136
# File 'lib/menudietetico/menu.rb', line 134

def porcion
  @porcion
end

#proteinasObject

Returns the value of attribute proteinas.



136
137
138
# File 'lib/menudietetico/menu.rb', line 136

def proteinas
  @proteinas
end

#tituloObject

Returns the value of attribute titulo.



131
132
133
# File 'lib/menudietetico/menu.rb', line 131

def titulo
  @titulo
end

#vctObject

Returns the value of attribute vct.



135
136
137
# File 'lib/menudietetico/menu.rb', line 135

def vct
  @vct
end

Instance Method Details

#getPlatosObject



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(options = {})
    plato = []
    plato << "#{options[:descripcion]}" if options[:descripcion]
    plato << "#{options[:porcion]}" if options[:porcion]
    plato << "#{options[:gramos]}" if options[: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(options = {})
    porcentaje = []
    porcentaje << "#{options[:min]}" if options[:min]
    porcentaje << "#{options[:max]}" if options[:max]
    @porcentaje = porcentaje

end

#porcentajes(options = {}) ⇒ Object



170
171
172
173
174
175
# File 'lib/menudietetico/menu.rb', line 170

def porcentajes(options = {})
    @vct = "#{options[:vct]}" if options[:vct]
    @proteinas = "#{options[:proteinas]}" if options[:proteinas]
    @grasas = "#{options[:grasas]}" if options[:grasas]
    @hidratos = "#{options[:hidratos]}" if options[:hidratos]
end

#to_sObject



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