SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ruby introspection question

    Hello,
    I am new to ruby and have a problem that might have a simple solution...

    Here is the problem:
    I would like the get the methods and their signatures that are available in a ruby object at runtime. These should not include the methods inherited from superclasses (ancestors).
    Is there a simple way of doing this?

    Thanks for your help,

    Makaks

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    >> obj = 4
    => 4
    >> obj.methods - obj.class.superclass.instance_methods
    => ["&#37;", "<<", "&", ">>", "*", "+", "-", "/", "|", "~", "to_f", "^", "**", "id2name", "size", "to_sym", "[]"]


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •