Forum: Ruby listing Object.methods

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
622fa8560c82dfaa59c91ec75efb0c19?d=identicon&s=25 Alex Combas (Guest)
on 2006-01-28 10:39
(Received via mailing list)
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.
5c7bdd14d6885c8275eaf78be41d120a?d=identicon&s=25 Eero Saynatkari (Guest)
on 2006-01-28 10:54
(Received via mailing list)
On 2006.01.28 18:39, Alex Combas wrote:
> 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
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-01-28 17:15
(Received via mailing list)
On Jan 28, 2006, at 3:52 AM, Eero Saynatkari wrote:

> On 2006.01.28 18:39, Alex Combas wrote:
>> Something like this, but better.
>>
>> `Foo.new.methods - Object.methods`
>
> 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
5c7bdd14d6885c8275eaf78be41d120a?d=identicon&s=25 Eero Saynatkari (Guest)
on 2006-01-28 22:09
(Received via mailing list)
On 2006.01.29 01:13, James Edward Gray II wrote:
>
> Do we really need a singleton class for that?  I prefer:
>
> self.class.instance_methods(false)

Yep, otherwise singleton methods will not be included.

> James Edward Gray II


E
This topic is locked and can not be replied to.