Sha256: 6a2f4b6c901bf460b1820061c45916fd64bde9830708faa7081d02a0a09e2be2

Contents?: true

Size: 691 Bytes

Versions: 214

Compression:

Stored size: 691 Bytes

Contents

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

214 entries across 170 versions & 24 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/core_ext/range/include_range.rb
activesupport-3.2.22.5 lib/active_support/core_ext/range/include_range.rb
activesupport-3.2.22.4 lib/active_support/core_ext/range/include_range.rb
activesupport-3.2.22.3 lib/active_support/core_ext/range/include_range.rb
activesupport-3.2.22.2 lib/active_support/core_ext/range/include_range.rb
activesupport-3.2.22.1 lib/active_support/core_ext/range/include_range.rb
classiccms-0.7.5 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/range/include_range.rb
classiccms-0.7.4 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/range/include_range.rb
classiccms-0.7.3 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/range/include_range.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/range/include_range.rb
activesupport-3.2.22 lib/active_support/core_ext/range/include_range.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.12/lib/active_support/core_ext/range/include_range.rb
activesupport-3.2.21 lib/active_support/core_ext/range/include_range.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/range/include_range.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/core_ext/range/include_range.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/activesupport-3.2.18/lib/active_support/core_ext/range/include_range.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/core_ext/range/include_range.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/range/include_range.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.18/lib/active_support/core_ext/range/include_range.rb
activesupport-3.2.20 lib/active_support/core_ext/range/include_range.rb