class Tsuga::Service::Aggregator::Pair
model a pair of clusters such as [a,b] == [b,a] and comparison is based on distance
Attributes
distance[RW]
Public Class Methods
new(c1, c2)
click to toggle source
# File lib/tsuga/service/aggregator.rb, line 116 def initialize(c1, c2) @left = c1 @right = c2 @left_id = c1.id @right_id = c2.id @distance = (@left & @right) raise ArgumentError, 'pair elements must be distinct' if @left_id == @right_id end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/tsuga/service/aggregator.rb, line 126 def <=>(other) self.distance <=> other.distance end
has?(c)
click to toggle source
# File lib/tsuga/service/aggregator.rb, line 138 def has?(c) c_id = c.id (@left_id == c_id) || (@right_id == c_id) end
values()
click to toggle source
def ==(other)
(self.left_id == other.left_id) && (self.right_id == other.right_id)
end
# File lib/tsuga/service/aggregator.rb, line 134 def values [@left, @right] end