ruby - List of instance methods of current class only -


i have instance o of class o. i'd know o capable of.

o.methods give me many methods. o.methods - object.instance_methods. not concise.

i want o.methods - o.class.superclass.instance_methods. is, methods defined in o itself.

is there other way?

you can use method module#instance_methods:

o.class.instance_methods(false) 


warning documentation seems wrong, says that:

with no argument, or with argument false, instance methods in mod returned, otherwise methods in mod , mod’s superclasses returned.

but parameter default true:

string.instance_methods.size # => 184 string.instance_methods(false).size # => 130 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -