Sha256: a4dbcbecf939a60b3939dfeb68f6471b3fbb5c0a1fd74ec5ffec0416ea60d976

Contents?: true

Size: 561 Bytes

Versions: 1

Compression:

Stored size: 561 Bytes

Contents

class Platodsl

    attr_accessor :nombre, :alimentos

    def initialize(nombre, &block)
        @nombre = nombre
        @alimentos = []

        if block_given?  
            if block.arity == 1
              yield self
            else
             instance_eval(&block) 
            end
        end
    end

    def alimento(aliment)
        @alimentos << aliment
    end

    def to_s
        output = "\n\n#{@nombre}"
        output << "\n#{'=' * @nombre.size}\n\n"
        output << "Alimentos: \n#{@alimentos.join(', ')}\n\n"
        output
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alimento-alu0100889635-0.1.0 lib/platodsl.rb