Module: GRATR::ArcNumber
Overview
This module provides for internal numbering of edges for differentiating 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
- #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
111 112 113 |
# File 'lib/gratr/edge.rb', line 111 def number @number end |
Class Method Details
.included(cl) ⇒ Object
Shortcut constructor. Instead of Arc.new(1,2) one can use Arc
128 129 130 131 132 133 |
# File 'lib/gratr/edge.rb', line 128 def self.included(cl) 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
122 |
# File 'lib/gratr/edge.rb', line 122 def <=>(rhs) (result = super(rhs)) == 0 ? number <=> rhs.number : result; end |
#==(rhs) ⇒ Object
125 |
# File 'lib/gratr/edge.rb', line 125 def ==(rhs) eql?(rhs); end |
#eql?(rhs) ⇒ Boolean
124 |
# File 'lib/gratr/edge.rb', line 124 def eql?(rhs) super(rhs) and (rhs.number.nil? or number.nil? or number == rhs.number); end |
#hash ⇒ Object
120 |
# File 'lib/gratr/edge.rb', line 120 def hash() super ^ number.hash; end |
#initialize(p_source, p_target, p_number, p_label = nil) ⇒ Object
113 114 115 116 |
# File 'lib/gratr/edge.rb', line 113 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
123 |
# File 'lib/gratr/edge.rb', line 123 def inspect() "#{self.class.to_s}[#{source.inspect},#{target.inspect},#{number.inspect},#{label.inspect}]"; end |
#reverse ⇒ Object
Returns (v,u) if self == (u,v).
119 |
# File 'lib/gratr/edge.rb', line 119 def reverse() self.class.new(target, source, number, label); end |
#to_s ⇒ Object
121 |
# File 'lib/gratr/edge.rb', line 121 def to_s() super + "[#{number}]"; end |