Class: Eg::AllPairs::Pair

Inherits:
Object
  • Object
show all
Defined in:
lib/eg/all_pairs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ Pair

Returns a new instance of Pair.



153
154
155
156
# File 'lib/eg/all_pairs.rb', line 153

def initialize left, right
  @left, @right = left, right
  @used = 0
end

Instance Attribute Details

#leftObject

Returns the value of attribute left.



151
152
153
# File 'lib/eg/all_pairs.rb', line 151

def left
  @left
end

#rightObject

Returns the value of attribute right.



151
152
153
# File 'lib/eg/all_pairs.rb', line 151

def right
  @right
end

#usedObject

Returns the value of attribute used.



152
153
154
# File 'lib/eg/all_pairs.rb', line 152

def used
  @used
end

Instance Method Details

#<=>(obj) ⇒ Object



163
164
165
# File 'lib/eg/all_pairs.rb', line 163

def <=> obj
  rank - obj.rank
end

#is_fit?(slug) ⇒ Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/eg/all_pairs.rb', line 157

def is_fit? slug
  @left.is_fit?(slug) and @right.is_fit?(slug)
end

#rankObject



160
161
162
# File 'lib/eg/all_pairs.rb', line 160

def rank
  AllPairs.rank * (AllPairs.rank * @used + @left.rank) + @right.rank
end