Skip to content

Commit

Permalink
refactor Range#include? for range value
Browse files Browse the repository at this point in the history
  • Loading branch information
nashby committed Dec 26, 2011
1 parent bec7cf2 commit 3f642c9
Showing 1 changed file with 1 addition and 3 deletions.
Expand Up @@ -9,9 +9,7 @@ class Range
# (5..9).include?(11) # => false
def include_with_range?(value)
if value.is_a?(::Range)
operator = exclude_end? ? :< : :<=
end_value = value.exclude_end? ? last.succ : last
include_without_range?(value.first) && (value.last <=> end_value).send(operator, 0)
min <= value.min && max >= value.max
else
include_without_range?(value)
end
Expand Down

0 comments on commit 3f642c9

Please sign in to comment.