Sha256: 60e076bcc31529166e7e329abc5018881d49c965072896b1a09526a5208e32b3

Contents?: true

Size: 319 Bytes

Versions: 1

Compression:

Stored size: 319 Bytes

Contents

# frozen_string_literal: true

class Range
  # Compare two ranges and see if they overlap each other
  #  (1..5).overlap?(4..6) # => true
  #  (1..5).overlap?(7..9) # => false
  def overlap?(other)
    other.begin == self.begin || cover?(other.begin) || other.cover?(self.begin)
  end

  alias :overlaps? :overlap?
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activesupport-7.1.0.beta1 lib/active_support/core_ext/range/overlap.rb