class Menu_DSL
Attributes
ingestas[RW]
instructions[RW]
name[RW]
ntitulo[RW]
platos[RW]
porcientos[RW]
Public Class Methods
new(name, &block)
click to toggle source
# File lib/dieta/dsl.rb, line 4 def initialize(name, &block) self.name = name self.ntitulo = [] self.ingestas = [] self.platos = [] self.instructions = [] self.porcientos = [] instance_eval &block end
Public Instance Methods
ingesta(options = {})
click to toggle source
# File lib/dieta/dsl.rb, line 19 def ingesta(options = {}) ingestas << " (#{options[:min]})" if options[:min] ingestas << " (#{options[:max]})" if options[:max] end
plato(options = {})
click to toggle source
# File lib/dieta/dsl.rb, line 24 def plato(options = {}) platos << " (#{options[:descripcion]})" if options[:descripcion] platos << " (#{options[:porcion]})" if options[:porcion] platos << " (#{options[:gramos]})" if options[:gramos] end
porcentajes(options = {})
click to toggle source
# File lib/dieta/dsl.rb, line 30 def porcentajes(options = {}) porcientos << " (#{options[:vct]})" if options[:vct] porcientos << " (#{options[:proteinas]})" if options[:proteinas] porcientos << " (#{options[:grasas]})" if options[:grasas] porcientos << " (#{options[:hidratos]})" if options[:hidratos] end
titulo(text, options = {})
click to toggle source
# File lib/dieta/dsl.rb, line 15 def titulo(text, options = {}) ntitulo << text end
to_s()
click to toggle source
# File lib/dieta/dsl.rb, line 37 def to_s output = "" output << "#{ntitulo.join(', ')}" output << "\n#{'=' * name.size}\n\n" output << "min: #{ingestas[0]} max: #{ingestas[1]}\n" output << "\nPlatos:\n" platos.each_with_index do |plato, index| output << "#{plato}" if index>0 if (index-1) % 3 == 1 output << "\n" end end end output << "\nPorcientos: vct:#{porcientos[0]}, proteinas:#{porcientos[1]} grasas:#{porcientos[2]} hidratos:#{porcientos[3]}\n" output end