class Tinydot::Node

Attributes

attrs[R]
edges[R]
name[R]

Public Class Methods

new(name, attrs) click to toggle source
# File lib/tinydot/node.rb, line 5
def initialize(name, attrs)
  @name = name
  @edges = []
  @attrs = attrs || {}
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/tinydot/node.rb, line 16
def <=>(other)
  @edges << Edge.new(self, other, dir: "both")
  other
end
>>(other) click to toggle source
# File lib/tinydot/node.rb, line 11
def >>(other)
  @edges << Edge.new(self, other)
  other
end
to_dot() click to toggle source
# File lib/tinydot/node.rb, line 21
def to_dot
  quoted_attrs = %i(label color fillcolor fontname)
  @attrs.map do |k, v|
    quoted_attrs.include?(k) ? %(#{k} = "#{v}") : %(#{k} = #{v})
  end.join(", ")
end