Class: GRATR::Edge
Overview
Direct Known Subclasses
Instance Method Summary collapse
-
#<=>(rhs) ⇒ Object
Sort support.
-
#eql?(other) ⇒ Boolean
(also: #==)
Equality allows for the swapping of source and target.
-
#hash ⇒ Object
Hash is defined such that source and target can be reversed and the hash value will be the same.
-
#to_s ⇒ Object
Edge.to_s == “(1=2 ‘label)”.
Methods inherited from Arc
[], #initialize, #inspect, #reverse
Constructor Details
This class inherits a constructor from GRATR::Arc
Instance Method Details
#<=>(rhs) ⇒ Object
Sort support
93 94 95 96 |
# File 'lib/gratr/edge.rb', line 93 def <=>(rhs) [[source,target].max,[source,target].min] <=> [[rhs.source,rhs.target].max,[rhs.source,rhs.target].min] end |
#eql?(other) ⇒ Boolean Also known as: ==
Equality allows for the swapping of source and target
81 |
# File 'lib/gratr/edge.rb', line 81 def eql?(other) super or (self.class == other.class and target==other.source and source==other.target); end |
#hash ⇒ Object
Hash is defined such that source and target can be reversed and the hash value will be the same
This will cause problems with self loops
90 |
# File 'lib/gratr/edge.rb', line 90 def hash() source.hash ^ target.hash; end |
#to_s ⇒ Object
Edge.to_s == “(1=2 ‘label)”
99 100 101 102 103 104 |
# File 'lib/gratr/edge.rb', line 99 def to_s l = label ? " '#{label.to_s}'" : '' s = source.to_s t = target.to_s "(#{[s,t].min}=#{[s,t].max}#{l})" end |