Knowing about objects is one part of reflection, but to get the whole
picture, you also need to be able to look at classes---the methods
and constants that they contain.
Looking at the class hierarchy is easy. You can get the parent of any
particular class using
superclasses and mixed-in modules.
klass = Fixnum
klass = klass.superclass
print " < " if klass
end while klass
Fixnum < Integer < Numeric < Object
[Fixnum, Integer, Precision, Numeric, Comparable, Object, Kernel]
If you want to build a complete class hierarchy, just run that code
for every class in the system. We can use
ObjectSpace.each_object(Class) do |aClass|