class MenuDSL
Attributes
grasas[RW]
hidratos[RW]
platos[RW]
porcentaje[RW]
porcion[RW]
proteinas[RW]
titulo[RW]
vct[RW]
Public Class Methods
new(name) { |self| ... }
click to toggle source
# 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
Public Instance Methods
getPlatos()
click to toggle source
# File lib/menudietetico/menu.rb, line 185 def getPlatos @platos.join(" ") end
in_platos(options = {})
click to toggle source
# 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 = {})
click to toggle source
# 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 = {})
click to toggle source
# 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_s()
click to toggle source
# 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