On 5/3/05, Ara.T.Howard <Ara.T.Howard / noaa.gov> wrote:
> 
> thoughts on how to do this
> 
>    class C
>      class << self
>        p un_metaclass #=> C
>      end
>    end
> 
> ??

heh... I was ahead of you on that one :) in the "inside_metaclass?"
thread, my solution returned the instance for the "true" value:

http://rubytalk.org/140390

class Class
 def metaclass?
   id = inspect[/\A\#<Class:\#<.+?\:0x(.+?)>>\Z/, 1]
   ObjectSpace._id2ref(id.to_i(16)/2) if id
 end
end

Note that this code is very fragile; it will not work on 1.6.x, and
isn't guaranteed to work in the future. It extracts the object_id of
the instance from the metaclass' inspect string.

cheers,
Mark