2007-12-21 08:48:59 +01:00
|
|
|
module ActiveSupport #:nodoc:
|
|
|
|
module CoreExtensions #:nodoc:
|
|
|
|
module Range #:nodoc:
|
|
|
|
# Check if Ranges overlap.
|
|
|
|
module Overlaps
|
2008-05-18 06:22:34 +02:00
|
|
|
# Compare two ranges and see if they overlap eachother
|
|
|
|
# (1..5).overlaps?(4..6) # => true
|
|
|
|
# (1..5).overlaps?(7..9) # => false
|
2007-12-21 08:48:59 +01:00
|
|
|
def overlaps?(other)
|
|
|
|
include?(other.first) || other.include?(first)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|