Sha256: 3abba45c5fff6d560e176ed11b8a772b7aa6b477a89cca719197c5b512202c8b

Contents?: true

Size: 676 Bytes

Versions: 17

Compression:

Stored size: 676 Bytes

Contents

unless (1..4).cover?(2..3)
  require 'backports/tools/alias_method_chain'

  class Range
    def cover_with_range_compatibility?(what)
      return cover_without_range_compatibility?(what) unless what.is_a?(Range)

      left = self.begin <=> what.begin
      right = self.end <=> what.end
      return false unless left && right

      left <= 0 && (
        right >= 1 ||
        right == 0 && (!exclude_end? || what.exclude_end?) ||
        what.exclude_end? && what.begin.is_a?(Integer) &&
          what.end.is_a?(Integer) && cover_without_range_compatibility?(what.end - 1)
      )
    end
    Backports.alias_method_chain self, :cover?, :range_compatibility
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
backports-3.25.0 lib/backports/2.6.0/range/cover.rb
backports-3.24.1 lib/backports/2.6.0/range/cover.rb
backports-3.24.0 lib/backports/2.6.0/range/cover.rb
backports-3.23.0 lib/backports/2.6.0/range/cover.rb
backports-3.22.1 lib/backports/2.6.0/range/cover.rb
backports-3.22.0 lib/backports/2.6.0/range/cover.rb
backports-3.21.0 lib/backports/2.6.0/range/cover.rb
backports-3.20.2 lib/backports/2.6.0/range/cover.rb
backports-3.20.1 lib/backports/2.6.0/range/cover.rb
backports-3.20.0 lib/backports/2.6.0/range/cover.rb
backports-3.19.0 lib/backports/2.6.0/range/cover.rb
backports-3.18.2 lib/backports/2.6.0/range/cover.rb
backports-3.18.1 lib/backports/2.6.0/range/cover.rb
backports-3.18.0 lib/backports/2.6.0/range/cover.rb
backports-3.17.2 lib/backports/2.6.0/range/cover.rb
backports-3.17.1 lib/backports/2.6.0/range/cover.rb
backports-3.17.0 lib/backports/2.6.0/range/cover.rb