File: active_support/core_ext/range/overlaps.rb

Overview
Module Structure
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: ActiveSupport#1
  module: CoreExtensions#2
  module: Range#3
  module: Overlaps#5
has properties
method: overlaps? / 1 #9

Code

   1  module ActiveSupport #:nodoc:
   2    module CoreExtensions #:nodoc:
   3      module Range #:nodoc:
   4        # Check if Ranges overlap.
   5        module Overlaps
   6          # Compare two ranges and see if they overlap eachother
   7          #  (1..5).overlaps?(4..6) # => true
   8          #  (1..5).overlaps?(7..9) # => false
   9          def overlaps?(other)
  10            include?(other.first) || other.include?(first)
  11          end
  12        end
  13      end
  14    end
  15  end