Justin Collins
1/16/2007 3:50:00 AM
Aaron Smith wrote:
> How can I find out what the super class is of an object, Say if a class
> extends Hash. I need to be able to find a string representation of the
> super class ('Hash').... is_a? won't work as that requires an actual
> module or class.. I need a string representation.
>
> any ideas? thanks.
Will Module#ancestors work?
irb(main):001:0> class A
irb(main):002:1> end
=> nil
irb(main):003:0> class B < A
irb(main):004:1> end
=> nil
irb(main):005:0> A.ancestors
=> [A, Object, Kernel]
irb(main):006:0> B.ancestors
=> [B, A, Object, Kernel]
-Justin