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

P

Peña, Botp

From: Kenneth McDonald [mailto:[email protected]]=20
# Subject: Is there a way to find the class methods of a class,=20
# just like 'methods' finds the instance methods?
# The subject says it all, really.


singleton_methods
 
S

Sebastian Hungerecker

Kenneth said:
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
 
K

Kenneth McDonald

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
 

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

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top