Debugging Method For Rubyclass Object

class Object
    def additional_methods
        if self.instance_of?(Class)
            self.methods.sort - Class.methods
        else
            self.methods.sort - Object.methods
        end
    end
end

#example usage
class Foo
    def self.a
    end
    def Foo.b
    end
    def c
    end
    def d
    end
end

{:class=>Foo,:instance=>Foo.new}.each do |name,obj|
    puts "#{name} additional methods: #{obj.additional_methods.join(',')}"
end

Posted

in

by

Tags: