class Menu_DSL
Attributes
descripcion[RW]
gramos[RW]
grasas[RW]
hidratos[RW]
ingesta_porcentajes[RW]
platos[RW]
porcion[RW]
proteinas[RW]
titulos[RW]
vct[RW]
Public Class Methods
new(titulos) { |self| ... }
click to toggle source
# File lib/menus/menu_dsl.rb, line 4 def initialize(titulos, &block) self.titulos = titulos self.platos = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end
Public Instance Methods
ingesta(options = {})
click to toggle source
# File lib/menus/menu_dsl.rb, line 21 def ingesta(options = {}) min_max = [] min_max << "#{options[:min]}" min_max << "#{options[:max]}" @ingesta_porcentajes = min_max end
plato(options = {})
click to toggle source
# File lib/menus/menu_dsl.rb, line 28 def plato(options = {}) ingredientes = [] ingredientes << "#{options[:descripcion]}, #{options[:porcion]}, #{options[:gramos]}" @platos.push(ingredientes) end
porcentajes(options = {})
click to toggle source
# File lib/menus/menu_dsl.rb, line 34 def porcentajes(options = {}) @vct = "#{options[:vct]}" @proteinas = "#{options[:proteinas]}" @grasas = "#{options[:grasas]}" @hidratos = "#{options[:hidratos]}" end
titulo(name)
click to toggle source
# File lib/menus/menu_dsl.rb, line 17 def titulo (name) @titulos = name end
to_s()
click to toggle source
# File lib/menus/menu_dsl.rb, line 41 def to_s buffer = "#{@titulos} " buffer << "(#{@ingesta_porcentajes.join(' - ')}%)\n" buffer << "- #{@platos.join("\n- ")}\n" buffer << "V.C.T. | % #{@vct} kcal | #{@proteinas}% - #{@grasas}% - #{@hidratos}%\n" end