Module: Plexus::ArcNumber
Overview
This module handles internal numbering of edges in order to differente between mutliple edges.
Instance Attribute Summary collapse
-
#number ⇒ Object
Used to differentiate between mutli-edges.
Class Method Summary collapse
-
.included(cl) ⇒ Object
Shortcut constructor.
Instance Method Summary collapse
- #<=>(rhs) ⇒ Object
- #==(rhs) ⇒ Object
- #eql?(rhs) ⇒ Boolean
-
#hash ⇒ Object
Allow for hashing of self loops.
- #initialize(p_source, p_target, p_number, p_label = nil) ⇒ Object
- #inspect ⇒ Object
-
#reverse ⇒ Object
Returns (v,u) if self == (u,v).
- #to_s ⇒ Object
Instance Attribute Details
#number ⇒ Object
Used to differentiate between mutli-edges
5 6 7 |
# File 'lib/plexus/arc_number.rb', line 5 def number @number end |
Class Method Details
.included(cl) ⇒ Object
Shortcut constructor. Instead of Arc.new(1,2) one can use Arc
43 44 45 46 47 48 |
# File 'lib/plexus/arc_number.rb', line 43 def self.included(cl) # FIXME: lacks a cl.class_eval, no? def cl.[](p_source, p_target, p_number = nil, p_label = nil) new(p_source, p_target, p_number, p_label) end end |
Instance Method Details
#<=>(rhs) ⇒ Object
26 27 28 |
# File 'lib/plexus/arc_number.rb', line 26 def <=>(rhs) (result = super(rhs)) == 0 ? number <=> rhs.number : result end |
#==(rhs) ⇒ Object
38 39 40 |
# File 'lib/plexus/arc_number.rb', line 38 def ==(rhs) eql?(rhs) end |
#eql?(rhs) ⇒ Boolean
34 35 36 |
# File 'lib/plexus/arc_number.rb', line 34 def eql?(rhs) super(rhs) and (rhs.number.nil? or number.nil? or number == rhs.number) end |
#hash ⇒ Object
Allow for hashing of self loops.
18 19 20 |
# File 'lib/plexus/arc_number.rb', line 18 def hash super ^ number.hash end |
#initialize(p_source, p_target, p_number, p_label = nil) ⇒ Object
7 8 9 10 |
# File 'lib/plexus/arc_number.rb', line 7 def initialize(p_source, p_target, p_number, p_label = nil) self.number = p_number super(p_source, p_target, p_label) end |
#inspect ⇒ Object
30 31 32 |
# File 'lib/plexus/arc_number.rb', line 30 def inspect "#{self.class.to_s}[#{source.inspect},#{target.inspect},#{number.inspect},#{label.inspect}]" end |
#reverse ⇒ Object
Returns (v,u) if self == (u,v).
13 14 15 |
# File 'lib/plexus/arc_number.rb', line 13 def reverse self.class.new(target, source, number, label) end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/plexus/arc_number.rb', line 22 def to_s super + "[#{number}]" end |