module RangeOperations::Pair
Public Class Methods
contiguous?(a, b)
click to toggle source
True if the extremeties of the two ranges touch
# File lib/range_operations/pair.rb, line 10 def self.contiguous?(a, b) a && b && (a.end == b.begin || b.end == a.begin) end
disjoint?(a, b)
click to toggle source
True if the ranges do not overlap and do not touch
# File lib/range_operations/pair.rb, line 15 def self.disjoint?(a, b) a && b && !a.cover?(b) && !b.cover?(a) end
merge(a, b)
click to toggle source
Make a Range form a’s begin and b’s end
# File lib/range_operations/pair.rb, line 20 def self.merge(a, b) a.begin .. b.end end
overlap?(a, b)
click to toggle source
True if sections of the two ranges overlap
# File lib/range_operations/pair.rb, line 5 def self.overlap?(a, b) a && b && (a.cover?(b.begin) || b.cover?(a.begin)) end