Sha256: 035fe6ba4d4e3e4ee514d7468bde9ad7ee71764ccf3e26e60e5a654d92f8de16

Contents?: true

Size: 292 Bytes

Versions: 33

Compression:

Stored size: 292 Bytes

Contents

# frozen_string_literal: true

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

Version data entries

33 entries across 32 versions & 8 rubygems

Version Path
activesupport-7.0.8.7 lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.8.6 lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.8.5 lib/active_support/core_ext/range/overlaps.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/core_ext/range/overlaps.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/core_ext/range/overlaps.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/core_ext/range/overlaps.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.8.4 lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.8.1 lib/active_support/core_ext/range/overlaps.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activesupport-7.0.3.1/lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.8 lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.7.2 lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.7.1 lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.7 lib/active_support/core_ext/range/overlaps.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/core_ext/range/overlaps.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.5/lib/active_support/core_ext/range/overlaps.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.6 lib/active_support/core_ext/range/overlaps.rb
activesupport-7.0.5.1 lib/active_support/core_ext/range/overlaps.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activesupport-7.0.3.1/lib/active_support/core_ext/range/overlaps.rb