Is there a way to find the class methods of a class, just like 'methods' finds the instance methods?

The subject says it all, really.

Thanks,
Ken

# Subject: Is there a way to find the class methods of a class,
# just like 'methods' finds the instance methods?
# The subject says it all, really.

singleton_methods

···

From: Kenneth McDonald [mailto:kenneth.m.mcdonald@sbcglobal.net]

p Class.methods

p File.methods

a @ http://codeforpeople.com/

···

On Sep 25, 2008, at 9:56 PM, Kenneth McDonald wrote:

The subject says it all, really.

Thanks,
Ken

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

Kenneth McDonald wrote:

Is there a way to find the class methods of a class, just like 'methods'
finds the instance methods?

methods does not give you the instance methods of a class. instance_methods
does. obj.methods (where obj might very well be a class) gives you all the
methods defined on obj, i.e. the instance methods of obj's class (minus the
ones you undefined for obj specifically, I suppose) + the singleton methods
that are defined on obj directly. If you specify the argument false, only the
singleton methods are listed.
So SomeClass.methods will list all the instance methods of class Class + all
the singleton (a.k.a. class-)methods of SomeClass and SomeClass.methods(false)
will give you only the latter.

HTH,
Sebastian

···

--
Jabber: sepp2k@jabber.org
ICQ: 205544826

Thanks everyone. It appears, then, that Ncurses.init_pair is not defined in the ncurses module,
regardless of what the ruby cookbook says. Sigh.

Ken

···

On Sep 26, 2008, at 2:58 AM, Sebastian Hungerecker wrote:

Kenneth McDonald wrote:

Is there a way to find the class methods of a class, just like 'methods'
finds the instance methods?

methods does not give you the instance methods of a class. instance_methods
does. obj.methods (where obj might very well be a class) gives you all the
methods defined on obj, i.e. the instance methods of obj's class (minus the
ones you undefined for obj specifically, I suppose) + the singleton methods
that are defined on obj directly. If you specify the argument false, only the
singleton methods are listed.
So SomeClass.methods will list all the instance methods of class Class + all
the singleton (a.k.a. class-)methods of SomeClass and SomeClass.methods(false)
will give you only the latter.

HTH,
Sebastian
--
Jabber: sepp2k@jabber.org
ICQ: 205544826