class NewDiet

Attributes

ingesta[RW]
platos[RW]
titulo[RW]
vct[RW]

Public Class Methods

new(name) { |self| ... } click to toggle source
# File lib/dieta/newdiet.rb, line 3
def initialize(name, &block)
        @titulo
        @ingesta = []
        @platos = []
        @porcentajes = []
        if block_given?
                if block.arity == 1
                        yield self
                else
                        instance_eval(&block)
                end
        end
end

Public Instance Methods

plato(options = {}) click to toggle source
# File lib/dieta/newdiet.rb, line 25
def plato(options = {})
        @platos << " (#{options[:descripcion]}), (#{options[:porcion]}), (#{options[:gramos]}) g" if options[:descripcion] && options[:porcion] && options[:gramos]
end
porcentajes(options = {}) click to toggle source
# File lib/dieta/newdiet.rb, line 29
      def porcentajes(options = {})
              @porcentajes << " (#{options[:vct]}) kcal | (#{options[:proteinas]})% - (#{options[:grasas]})% - (#{options[:hidratos]})%" if options[:vct] && options[:grasas] && options[:hidratos]
end
to_s() click to toggle source
# File lib/dieta/newdiet.rb, line 33
def to_s
        output = ""
        output << "#{@titulo} (#{@ingesta})\n"
        @platos.each do |plato|
                output << "-#{plato}\n"
        end
        output << "V.C.T. | % \t#{@porcentajes}\n"
end