Sha256: 3108a41795bfabc706c4aff987fd5c88c34619fe0dacda26f0212211fa584471
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
class Menu_dsl attr_accessor :etiqueta, :titulo, :ingesta, :plato, :porcentaje def initialize(etiqueta, &block) self.etiqueta = etiqueta self.titulo = "" self.ingesta = [] self.plato = [] self.porcentaje = [] if block_given? if block.arity == 1 yield self else instance_eval(&block) end end end def titulos(options = {}) titulo << "#{options[:titulo]}" end def ingestas(options = {}) ingesta << "#{options[:max]}" if options[:max] ingesta << "#{options[:min]}" if options[:min] end def platos(options = {}) pl = [] pl << "#{options[:descPlato]}" if options[:descPlato] pl << "#{options[:descPorcion]}" if options[:descPorcion] pl << "#{options[:ingestaGramos]}" if options[:ingestaGramos] plato << pl end def porcentajes(options = {}) pc = [] pc << "#{options[:vct]}" if options[:vct] pc << "#{options[:proteinas]}" if options[:proteinas] pc << "#{options[:grasas]}" if options[:grasas] pc << "#{options[:hidratos]}" if options[:hidratos] porcentaje << pc end def to_s output = etiqueta output << "\n#{'=' * etiqueta.size}\n\n" output << "#{titulo}" output << "(#{ingesta[0]} - #{ingesta[1]}%) \n" plato.each_with_index do |plato, index| output << "- #{plato[0]}, #{plato[1]}, #{plato[2]}g\n" end porcentaje.each_with_index do |porcentaje, index| output << "V.C.T. | % #{porcentaje[0]}Kcal | #{porcentaje[1]}% - #{porcentaje[2]}% - #{porcentaje[3]}%\n" end output end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
menualu0100782851-0.1.1 | lib/prct11/menu_dsl.rb |