Sha256: b1393e6af9823381b9c02fce0b5eef8e0d71c9156434e36c1d25cec17317286a

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

class NewDiet
	attr_accessor :titulo, :ingesta, :platos, :vct
	def initialize(name, &block)
		@titulo
		@ingesta = []
		@platos = []
		@porcentajes = []
		if block_given?
			if block.arity == 1
				yield self
			else
				instance_eval(&block)
			end
		end
	end

	def titulo(title)
		@titulo = title
	end

	def ingesta(options = {})
		@ingesta << " (#{options[:min]}) - (#{options[:max]})" if options[:min] && options[:max]
	end

	def plato(options = {})
		@platos << " (#{options[:descripcion]}), (#{options[:porcion]}), (#{options[:gramos]}) g" if options[:descripcion] && options[:porcion] && options[:gramos]
	end

	def porcentajes(options = {})
		@porcentajes << " (#{options[:vct]}) kcal | (#{options[:proteinas]})% - (#{options[:grasas]})% - (#{options[:hidratos]})%" if options[:vct] && options[:grasas] && options[:hidratos]
  end

	def to_s
		output = ""
		output << "#{@titulo} (#{@ingesta})\n"
		@platos.each do |plato|
                        output << "-#{plato}\n"
                end
		output << "V.C.T. | % \t#{@porcentajes}\n"
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Gema_alu0100891485-0.1.0 lib/dieta/newdiet.rb