Sha256: 569676f8bcb7e6db5ad8d0e09439da7e5a5a46f21d572e43c3809a7fea4da3ba

Contents?: true

Size: 363 Bytes

Versions: 5

Compression:

Stored size: 363 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).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

5 entries across 5 versions & 1 rubygems

Version Path
ruco-0.4.0 lib/ruco/core_ext/range.rb
ruco-0.3.0 lib/ruco/core_ext/range.rb
ruco-0.2.23 lib/ruco/core_ext/range.rb
ruco-0.2.22 lib/ruco/core_ext/range.rb
ruco-0.2.21 lib/ruco/core_ext/range.rb