Class: Rviz::Edge

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/rviz/edge.rb

Overview

represent a ->

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#attrs_to_s, #quote, #set

Constructor Details

#initialize(from_node, from_anchor, to_node, to_anchor = nil, attributes = {}) ⇒ Edge

Returns a new instance of Edge.



6
7
8
# File 'lib/rviz/edge.rb', line 6

def initialize from_node, from_anchor, to_node, to_anchor = nil, attributes = {}
  @from, @from_anchor, @to, @to_anchor, @attrs = from_node, from_anchor, to_node, to_anchor, attributes
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



4
5
6
# File 'lib/rviz/edge.rb', line 4

def attrs
  @attrs
end

Instance Method Details

#node_anchor(node, anchor) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rviz/edge.rb', line 10

def node_anchor node, anchor
  if anchor and anchor.size > 0
    quote(node) + ":" + anchor
  else
    quote(node)
  end
end

#to_sObject

output to dot format



21
22
23
24
25
26
27
28
# File 'lib/rviz/edge.rb', line 21

def to_s
  from, to = node_anchor(@from, @from_anchor), node_anchor(@to, @to_anchor)
  if @attrs.keys.size > 0
    sprintf "%s -> %s [%s]", from, to, self.attrs_to_s
  else
    sprintf "%s -> %s", from, to
  end
end