class GraphViz::DOTScript
Public Class Methods
new()
click to toggle source
# File lib/graphviz/dot_script.rb, line 53 def initialize @script = '' end
Public Instance Methods
add_type(type, data)
click to toggle source
# File lib/graphviz/dot_script.rb, line 74 def add_type(type, data) return self if data.empty? case type when "graph_attr" append_statement(" " + data) when "node_attr" append_statement(" node [" + data + "]") when "edge_attr" append_statement(" edge [" + data + "]") else raise ArgumentError, "Unknown type: #{type}." << "Possible: 'graph_attr','node_attr','edge_attr'" end self end
append(line)
click to toggle source
# File lib/graphviz/dot_script.rb, line 57 def append(line) @script << assure_ends_with(line.to_s,"\n") self end
Also aliased as: <<
make_subgraph(name)
click to toggle source
# File lib/graphviz/dot_script.rb, line 70 def make_subgraph(name) prepend(assure_ends_with("subgraph #{name}"," {")) end
prepend(line)
click to toggle source
# File lib/graphviz/dot_script.rb, line 64 def prepend(line) @script = assure_ends_with(line.to_s,"\n") + @script self end
to_str()
click to toggle source
# File lib/graphviz/dot_script.rb, line 93 def to_str @script end
Also aliased as: to_s
Private Instance Methods
append_statement(statement)
click to toggle source
# File lib/graphviz/dot_script.rb, line 104 def append_statement(statement) append(assure_ends_with(statement, ";\n")) end
assure_ends_with(str,ending="\n")
click to toggle source
# File lib/graphviz/dot_script.rb, line 100 def assure_ends_with(str,ending="\n") str.to_s.end_with?("\n") ? str : str + ending end