From: Jonathan Rochkind Date: 2009-06-17T06:42:48+09:00 Subject: Re: list methods only for specific class Steve Ross wrote: > Often, I'm most interested in methods unique to a given class and not > those inherited from, say, Object: > > (Array.instance_methods - Array.private_instance_methods - > Object.public_methods).sort > > And I sort them for easier reference. Don't know if this adds any > information... If you really want unique to the class, and the class may have a more complex object hieararchy than just inheriting from Object, why not something like: (MyClass.methods - MyClass.superclass.methods) I _think_ that'll work, although how included modules in MyClass are treated should be tested experimentally. I think it'll still work cause of the magic anonymous singleton class thing ruby uses for module mix-ins and such. The trick in both Steve's and my attempt is the really useful '-' operator/method on Arrays, which does array difference. So useful! See also '&' for array intersection. Can save you a lot of hacky code if you remember they're there. Jonathan -- Posted via http://www.ruby-forum.com/.