Last active
January 2, 2022 13:07
-
-
Save IFilonov/e1b5625045959a88a905ad8d5b9720d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| anc_desc= {} | |
| ObjectSpace.each_object(Class).select{ |x| x < Object }.each{ |c| anc_desc[c.name] = c.superclass.name if c.name && c.superclass.name } | |
| File.open'result.dot', 'w' do |file| | |
| file.puts %Q(digraph "Ruby#{RUBY_VERSION}" {\n) | |
| file.puts %Q(node [shape=box];\n edge [arrowtail="empty", dir=back];\n) | |
| anc_desc.each.sort_by { |desc, anc| anc + desc }.each{ |desc, anc| file.puts %Q("#{anc}" -> "#{desc}";\n)} | |
| #anc_desc.each{|desc, anc|file.puts%Q("#{anc}" -> "#{desc}";\n)} | |
| file.puts'}'; | |
| end | |
| system 'dot -Tsvg result.dot -o ruby.svg' | |
| --before in ubuntu | |
| sudo apt install graphviz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment