class Range

1.9's Range#cover? is equivalent to 1.8 Range#include? (redmine.ruby-lang.org/issues/show/736)

Add a couple of helper methods to the standard Range class so that we can determine various containment relationships.

Public Instance Methods

overlaps?(other) click to toggle source

Return true if this range overlaps the given range.

# File buryspam.rb, line 148
def overlaps?(other)
  self.begin <= other.end && self.end >= other.begin
end
within?(other) click to toggle source

Return true if this range lies entirely within the given range.

# File buryspam.rb, line 153
def within?(other)
  self.begin >= other.begin && self.end <= other.end
end