Method: RubyGraphviz#node

Defined in:
lib/ruby_graphviz.rb

#node(node_id, node_hash = nil) ⇒ Object

Create a node with its options

Example:

graph.node("node-01", :label => "Node 01", :fillcolor => "pink")


115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/ruby_graphviz.rb', line 115

def node(node_id, node_hash = nil)
  @dot << "  #{node_id.to_s}"
  index = 0
  if node_hash
    @dot << " ["
    node_hash.each do |k, v|
      k = k.to_s
      @dot << "#{k} = \"#{v}\""
      index += 1
      @dot << ", " unless index == node_hash.size
    end
    @dot << "]"
  end
  @dot << ";\n"
  self
end