Sha256: 2eb4985088d125c7e4091eff8c300238be078ec7eb3f8dca912da5d12687b838
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
class Menu_DSL attr_accessor :name, :ntitulo, :ingestas, :platos, :instructions, :porcientos def initialize(name, &block) self.name = name self.ntitulo = [] self.ingestas = [] self.platos = [] self.instructions = [] self.porcientos = [] instance_eval &block end def titulo(text, options = {}) ntitulo << text end def ingesta(options = {}) ingestas << " (#{options[:min]})" if options[:min] ingestas << " (#{options[:max]})" if options[:max] end def plato(options = {}) platos << " (#{options[:descripcion]})" if options[:descripcion] platos << " (#{options[:porcion]})" if options[:porcion] platos << " (#{options[:gramos]})" if options[:gramos] end 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 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dieta_alu0100648782-0.1.0 | lib/dieta/dsl.rb |