Sha256: 5890b943089863cb6ed1526f479200ea355c6de52011b7b2d8ff3c4173e90e01
Contents?: true
Size: 513 Bytes
Versions: 30
Compression:
Stored size: 513 Bytes
Contents
class Range # http://stackoverflow.com/questions/699448/ruby-how-do-you-check-whether-a-range-contains-a-subset-of-another-range def overlap?(other) (first <= other.last) and (other.first <= last) end # (1..2).last_element == 2 # (1...3).last_element == 2 def last_element exclude_end? ? last.pred : last end unless defined? last_element # (1..2).move(2) == (3..4) def move(n) if exclude_end? (first + n)...(last + n) else (first + n)..(last + n) end end end
Version data entries
30 entries across 30 versions & 1 rubygems