Class: Plexus::Edge
Overview
Direct Known Subclasses
Instance Method Summary collapse
-
#<=>(rhs) ⇒ Object
Sort support.
-
#eql?(other) ⇒ Boolean
(also: #==)
Edge 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
Methods inherited from Arc
[], #initialize, #inspect, #reverse
Constructor Details
This class inherits a constructor from Plexus::Arc
Instance Method Details
#<=>(rhs) ⇒ Object
Sort support
21 22 23 |
# File 'lib/plexus/edge.rb', line 21 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: ==
Edge equality allows for the swapping of source and target.
8 9 10 11 |
# File 'lib/plexus/edge.rb', line 8 def eql?(other) same_class = self.class.ancestors.include?(other.class) || other.class.ancestors.include?(self.class) super || (same_class && target == other.source && 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
16 17 18 |
# File 'lib/plexus/edge.rb', line 16 def hash source.hash ^ target.hash end |