listing Object.methods

Discussion in 'Ruby' started by Alex Combas, Jan 28, 2006.

  1. Alex Combas

    Alex Combas Guest

    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/
     
    Alex Combas, Jan 28, 2006
    #1
    1. Advertising

  2. 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
     
    Eero Saynatkari, Jan 28, 2006
    #2
    1. Advertising

  3. 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
     
    James Edward Gray II, Jan 28, 2006
    #3
  4. 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
     
    Eero Saynatkari, Jan 28, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KevD711
    Replies:
    1
    Views:
    384
    bruce barker
    Feb 11, 2008
  2. Robert P. J. Day

    listing an object's methods/attributes?

    Robert P. J. Day, Nov 6, 2009, in forum: Python
    Replies:
    0
    Views:
    312
    Robert P. J. Day
    Nov 6, 2009
  3. John Maclean

    listing methods within the debugger

    John Maclean, Jul 8, 2008, in forum: Ruby
    Replies:
    0
    Views:
    92
    John Maclean
    Jul 8, 2008
  4. Kenneth McDonald
    Replies:
    5
    Views:
    345
    Kenneth McDonald
    Sep 26, 2008
  5. Jason Lillywhite

    show a listing of methods unique to class

    Jason Lillywhite, Aug 18, 2009, in forum: Ruby
    Replies:
    4
    Views:
    106
    Jason Lillywhite
    Aug 18, 2009
Loading...

Share This Page