233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/better_ranges/sparse_range.rb', line 233
def <=>(other)
comp = nil
if other.is_a?(Range) || other.is_a?(BetterRanges::SparseRange)
comp = (first <=> other.first)
comp = (last <=> other.last) if comp == 0
if comp == 0
comp = -1 if exclude_end? && !other.exclude_end?
comp = 1 if !exclude_end? && other.exclude_end?
end
else
comp = (first <=> other)
comp = (last <=> other) if comp == 0
comp = -1 if comp == 0 && exclude_end?
end
comp
end
|