Sha256: bce57414d0e92b9e3dddd90557da1bd9d36645a890595c54559b607dab4117b8

Contents?: true

Size: 514 Bytes

Versions: 2

Compression:

Stored size: 514 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
    Dispel::Tools.last_element(self)
  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

2 entries across 2 versions & 1 rubygems

Version Path
ruco-0.2.20 lib/ruco/core_ext/range.rb
ruco-0.2.19 lib/ruco/core_ext/range.rb