This commit is contained in:
Jörg Thalheim 2014-02-07 07:55:04 +01:00
parent 98b613b9b8
commit d7da41e38d
2 changed files with 31 additions and 0 deletions

BIN
ahnen.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 KiB

31
geanology.rb Normal file
View File

@ -0,0 +1,31 @@
class Node
attr_reader :style
attr_accessor :childs
def initialize(style)
@style = style
@childs = []
end
end
nodes = {}
f = File.open("ahnen.dot.txt","r")
f.each_line do |line|
case line
# Label1 -> Label1 [style...]
when /^\s*(\S+)\s*->\s*(\S+)\s*\[([^\]]+)\]/
parent, child, style = $1, $2, $3
if not nodes[child]
$stderr.puts("child not found '#{child}'")
elsif not nodes[parent]
$stderr.puts("parent not found '#{parent}'")
else
nodes[parent].childs << child
end
# Label [style...]
when /^\s*(\S+)\s+\[([^\]]+)\]/
node, style = $1, $2
nodes[node] = Node.new(style)
else
#print "ignore -> #{line}"
end
end