Listing Methods Unique to an Object
class Object
def my_methods_only
my_super = self.class.superclass
return my_super ? methods - my_super.instance_methods : methods
end
end
p s = ''
p s.methods.size # => 143
p Object.instance_methods.size # => 41
p s.my_methods_only.size # => 102
p (s.methods - Object.instance_methods).size # => 102
Related examples in the same category