Sha256: e6e92907277c2cd53bce202e940a2f29d27665d1b3d6b351f8568dba46c58148

Contents?: true

Size: 681 Bytes

Versions: 5

Compression:

Stored size: 681 Bytes

Contents

require 'furnace/base'

module Furnace::Graphviz
  def initialize
    @code = "digraph {\n"
    @code << "node [labeljust=l,nojustify=true,fontname=monospace];"
    @code << "rankdir=TB;"

    yield self

    @code << "}"
  end

  def node(name, content)
    content.gsub!("&", "&amp;")
    content.gsub!(">", "&gt;")
    content.gsub!("<", "&lt;")
    content = content.lines.map { |l| %Q{<tr><td align="left">#{l}</td></tr>} }.join

    @code << %Q{#{name.inspect} [shape=box,label=<<table border="0">#{content}</table>>];\n}
  end

  def edge(from, to, label="")
    @code << %Q{#{from.inspect} -> #{to.inspect} [label=#{label.inspect}];\n}
  end

  def to_s
    @code
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
furnace-0.0.8 lib/furnace/graphviz.rb
furnace-0.0.7 lib/furnace/graphviz.rb
furnace-0.0.6 lib/furnace/graphviz.rb
furnace-0.0.4 lib/furnace/graphviz.rb
furnace-0.0.3 lib/furnace/graphviz.rb