Permalink
Browse files

Range#=== is not an alias for #include? on 1.9

  • Loading branch information...
1 parent b0d2e6d commit d1ecf2c4a40685a1c66d8946260a090755d0cc63 @jfirebaugh jfirebaugh committed Jul 27, 2012
Showing with 9 additions and 4 deletions.
  1. +2 −3 kernel/common/range.rb
  2. +2 −0 kernel/common/range18.rb
  3. +5 −1 kernel/common/range19.rb
View
5 kernel/common/range.rb
@@ -32,7 +32,7 @@ def ==(other)
end
alias_method :eql?, :==
- def ===(value)
+ def include?(value)
# MRI uses <=> to compare, so must we.
beg_compare = (@begin <=> value)
@@ -49,8 +49,7 @@ def ===(value)
return false
end
- alias_method :member?, :===
- alias_method :include?, :===
+ alias_method :member?, :include?
attr_reader_specific :excl, :exclude_end?
View
2 kernel/common/range18.rb
@@ -1,6 +1,8 @@
# -*- encoding: us-ascii -*-
class Range
+ alias_method :===, :include?
+
protected
def can_iterate_from?(object)
View
6 kernel/common/range19.rb
@@ -1,7 +1,11 @@
# -*- encoding: us-ascii -*-
class Range
- alias_method :cover?, :===
+ def ===(value)
+ include?(value)
+ end
+
+ alias_method :cover?, :include?
def max(&block)
raise TypeError, "cannot exclude non Integer end value" if @end.kind_of?(Float) && @excl

0 comments on commit d1ecf2c

Please sign in to comment.