listing Object.methods

A

Alex Combas

Hello,
Tonight I was thinking that it would be handy to
have a way to list all the methods in a class but
not list any of the standard methods that it inherits
from its parent object enless they have been added
to by the class in question.

Something like this, but better.

`Foo.new.methods - Object.methods`

For example if Foo reimplenents .to_s then I would like to know about it.
 
E

Eero Saynatkari

Hello,
Tonight I was thinking that it would be handy to
have a way to list all the methods in a class but
not list any of the standard methods that it inherits
from its parent object enless they have been added
to by the class in question.

Something like this, but better.

`Foo.new.methods - Object.methods`

As a workaround, you can do this:

class << foo; self; end.instance_methods false
For example if Foo reimplenents .to_s then I would like to know about it.

Alex Combas


E
 
J

James Edward Gray II

As a workaround, you can do this:

class << foo; self; end.instance_methods false

Do we really need a singleton class for that? I prefer:

self.class.instance_methods(false)

James Edward Gray II
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top