Sha256: cc9365746ae0f0f48228b17af93b63da641ba3e762c6fbe4dea34135d6ad00db
Contents?: true
Size: 990 Bytes
Versions: 2
Compression:
Stored size: 990 Bytes
Contents
module ReVIEW class HTMLToc def initialize(basedir) @tochtmltxt = "toc-html.txt" @basedir = basedir end def add_item(level, filename, title, args) args_str = encode_args(args) line = [level, filename, title, args_str].join("\t") File.open(tocfilename, "a") do |f| f.write "#{line}\n" end end def each_item File.open(tocfilename) do |f| f.each_line do |line| level, file, title, args_str = line.chomp.split("\t") args = decode_args(args_str) yield level, file, title, args end end end def tocfilename File.join(@basedir, @tochtmltxt) end def decode_args(args_str) args = Hash.new args_str.split(/,\s*/).each do |pair| key, val = pair.split("=") args[key.to_sym] = val end args end def encode_args(args) args.delete_if {|k,v| v.nil? }.map{|k,v| "#{k}=#{v}"}.join(",") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
review-2.1.0 | lib/review/htmltoc.rb |
review-2.0.0 | lib/review/htmltoc.rb |