ObjectGraph: a Ruby class inheritance hierarchy graph

Unfortunately I don’t read Swedish (and could find an online translation
engine :). Anyway, I didn’t see a tree there.

There seem to be a couple of issues with you code. Note below.

expand -t2 ruby_exceptions.rb
parents =
ObjectSpace.each_object do |obj|
if obj.class == Class and obj.superclass == Exception

To get Class objects you can use:
ObjectSpace.each_object(Class) { |klass|

}

#puts "class-derived-from-exc #{obj}"
parents << obj

end
end
#p parents

result = {}
parents.each {|klass| result[klass.to_s] = }

ObjectSpace.each_object do |obj|
parents.each do |cls|
if obj.class == Class and obj.superclass == cls
#puts “child of #{cls}: #{obj}”
result[cls.to_s] << obj.to_s
end
end
end

Unless I’m mistaken, in this way you only get two levels of indirection.
You won’t see stuff like:
EOFError → IOError → StandardError → Exception.
Your loop stops at IOError.