Building an “include” graph

How easy would it be to build include graphs in ruby?

Here’s my first attempt:

$list_of_files = Hash.new
$list_of_files.each {|node|
	node = Array.new
}

def store_includes(pathname)
	lines = IO.readlines(pathname)
	lines.each {|line|
		if line.include? “#include”
			include_file = line[line.index("#include")+"#include".size,line.size]
			fidx = 0
			sidx = 0

			if include_file.include?(“”")
				fidx = include_file.index(“”") + 1
				sidx = include_file.index(“”",fidx+1) – 1
			end

			if include_file.include?(‘< ')
				fidx = include_file.index('<') + 1
				sidx = include_file.index('>‘) – 1
			end

			include_file = include_file[fidx..sidx]
			$list_of_files[pathname].add(include_file)
		end
	}
end

def iterate_files(pathname)
	list = [] #alternate way of initializing an array
	if pathname==”.” or pathname==nil
		list = Dir["*"]
	else
		list = Dir[pathname + File::SEPERATOR + "*"]
	end
	list.each { |path|
		if File.filetype(path) == “directory”
			iterate_files(pathname)
		end
		if File.filetype(path) == “file”
			store_includes(path)
		end
	}
end

Any comments?