Listing Methods Unique to an Object : Method Reflection « Reflection « Ruby






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

1.query almost any object within Ruby for the methods that are defined within it
2.Sort all method from Object
3.Getting a Reference to a Method
4.Method pointer