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.
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…
is_a? won’t report an inheritance relationship in any case:
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]