Sha256: c9298c3243267e0a03329342dca6b10a66c416a751d3b6caf7322dacfabca61a

Contents?: true

Size: 731 Bytes

Versions: 75

Compression:

Stored size: 731 Bytes

Contents

module ActiveSupport
  module IncludeWithRange #:nodoc:
    # Extends the default Range#include? to support range comparisons.
    #  (1..5).include?(1..5) # => true
    #  (1..5).include?(2..3) # => true
    #  (1..5).include?(2..6) # => false
    #
    # The native Range#include? behavior is untouched.
    #  ('a'..'f').include?('c') # => true
    #  (5..9).include?(11) # => false
    def include?(value)
      if value.is_a?(::Range)
        # 1...10 includes 1..9 but it does not include 1..10.
        operator = exclude_end? && !value.exclude_end? ? :< : :<=
        super(value.first) && value.last.send(operator, last)
      else
        super
      end
    end
  end
end

Range.prepend(ActiveSupport::IncludeWithRange)

Version data entries

75 entries across 72 versions & 9 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.0.7.1/lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.7 lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.7.rc1 lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.6.2 lib/active_support/core_ext/range/include_range.rb
activesupport-5.0.7.2 lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.6.1 lib/active_support/core_ext/range/include_range.rb
activesupport-5.0.7.1 lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.6 lib/active_support/core_ext/range/include_range.rb
activesupport-5.0.7 lib/active_support/core_ext/range/include_range.rb
tdiary-5.0.8 vendor/bundle/gems/activesupport-5.1.5/lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.5 lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.5.rc1 lib/active_support/core_ext/range/include_range.rb
pract6-0.1.0 .gem/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.4 lib/active_support/core_ext/range/include_range.rb
activesupport-5.0.6 lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.4.rc1 lib/active_support/core_ext/range/include_range.rb
activesupport-5.0.6.rc1 lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.3 lib/active_support/core_ext/range/include_range.rb
activesupport-5.1.3.rc3 lib/active_support/core_ext/range/include_range.rb
activesupport-5.0.5 lib/active_support/core_ext/range/include_range.rb