Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > listing Object.methods

Reply
Thread Tools

listing Object.methods

 
 
Alex Combas
Guest
Posts: n/a
 
      01-28-2006
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.

--
Alex Combas
http://noodlejunkie.blogspot.com/


 
Reply With Quote
 
 
 
 
Eero Saynatkari
Guest
Posts: n/a
 
      01-28-2006
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


 
Reply With Quote
 
 
 
 
James Edward Gray II
Guest
Posts: n/a
 
      01-28-2006
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


 
Reply With Quote
 
Eero Saynatkari
Guest
Posts: n/a
 
      01-28-2006
On 2006.01.29 01:13, James Edward Gray II wrote:
> 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)


Yep, otherwise singleton methods will not be included.

> James Edward Gray II



E


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing installed perl modules gusmeister Perl 3 03-03-2004 08:57 PM
Cisco 678 long listing since CBOS upgrade S. Smith Cisco 0 02-10-2004 06:43 PM
Listing MAC Table with SNMP Michel Lapointe Cisco 2 11-07-2003 01:40 PM
Directory Listing JD Perl 0 08-23-2003 11:53 PM
Listing processes using Perl (Win32) Filipe Bonjour Perl 0 07-26-2003 04:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57