Look at an object's ancestors with Module's ancestors method, which returns a list of both classes and modules : ancestors « Reflection « Ruby






Look at an object's ancestors with Module's ancestors method, which returns a list of both classes and modules


myString = "asdf"

p myString.class.ancestors # => [String, Enumerable, Comparable, Object, Kernel]
p String.ancestors # => [String, Enumerable, Comparable, Object, Kernel]

 








Related examples in the same category

1.Get ancestors