Sha256: 8c4a0ccdc466d9964abfabf25ee02d0a1c0ee2e8cb5978aeaaaac5c510be91d9

Contents?: true

Size: 742 Bytes

Versions: 130

Compression:

Stored size: 742 Bytes

Contents

require 'active_support/core_ext/module/aliasing'

class Range
  # 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_with_range?(value)
    if value.is_a?(::Range)
      # 1...10 includes 1..9 but it does not include 1..10.
      operator = exclude_end? && !value.exclude_end? ? :< : :<=
      include_without_range?(value.first) && value.last.send(operator, last)
    else
      include_without_range?(value)
    end
  end

  alias_method_chain :include?, :range
end

Version data entries

130 entries across 125 versions & 13 rubygems

Version Path
activesupport-4.2.11.3 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.11.2 lib/active_support/core_ext/range/include_range.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/core_ext/range/include_range.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.11.1 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.11 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.10 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.10.rc1 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.9 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.9.rc2 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.9.rc1 lib/active_support/core_ext/range/include_range.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activesupport-4.2.8/lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.8 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.8.rc1 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.7.1 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.7 lib/active_support/core_ext/range/include_range.rb
activesupport-4.1.16 lib/active_support/core_ext/range/include_range.rb
activesupport-4.1.16.rc1 lib/active_support/core_ext/range/include_range.rb
activesupport-4.2.7.rc1 lib/active_support/core_ext/range/include_range.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/core_ext/range/include_range.rb