Class: Gviz::Edge

Inherits:
Struct show all
Defined in:
lib/gviz/edge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, attrs = {}) ⇒ Edge

Returns a new instance of Edge.

Raises:

  • (ArgumentError)


3
4
5
6
7
# File 'lib/gviz/edge.rb', line 3

def initialize(id, attrs={})
  raise ArgumentError, "edge `attrs` must a hash" unless attrs.is_a?(Hash)
  id, @st, @ed, @seq, @st_port, @ed_port = parse_id(id)
  super(id, attrs)
end

Instance Attribute Details

#attrsObject

Returns the value of attribute attrs

Returns:

  • (Object)

    the current value of attrs



1
2
3
# File 'lib/gviz/edge.rb', line 1

def attrs
  @attrs
end

#edObject (readonly)

Returns the value of attribute ed.



2
3
4
# File 'lib/gviz/edge.rb', line 2

def ed
  @ed
end

#ed_portObject (readonly)

Returns the value of attribute ed_port.



2
3
4
# File 'lib/gviz/edge.rb', line 2

def ed_port
  @ed_port
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



1
2
3
# File 'lib/gviz/edge.rb', line 1

def id
  @id
end

#seqObject (readonly)

Returns the value of attribute seq.



2
3
4
# File 'lib/gviz/edge.rb', line 2

def seq
  @seq
end

#stObject (readonly)

Returns the value of attribute st.



2
3
4
# File 'lib/gviz/edge.rb', line 2

def st
  @st
end

#st_portObject (readonly)

Returns the value of attribute st_port.



2
3
4
# File 'lib/gviz/edge.rb', line 2

def st_port
  @st_port
end

Instance Method Details

#nodesObject



16
17
18
# File 'lib/gviz/edge.rb', line 16

def nodes
  [st, ed]
end

#to_sObject



9
10
11
12
13
14
# File 'lib/gviz/edge.rb', line 9

def to_s
  stp = ":#{st_port}" if st_port
  edp = ":#{ed_port}" if ed_port
  edge = $graph_type==:graph ? "--" : "->"
  "#{st}#{stp} #{edge} #{ed}#{edp}"
end