Class: Range

Inherits:
Object show all
Defined in:
lib/ruco/core_ext/range.rb

Instance Method Summary collapse

Instance Method Details

#move(n) ⇒ Object

(1..2).move(2) == (3..4)



8
9
10
11
12
13
14
# File 'lib/ruco/core_ext/range.rb', line 8

def move(n)
  if exclude_end?
    (first + n)...(last + n)
  else
    (first + n)..(last + n)
  end
end

#overlap?(other) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/ruco/core_ext/range.rb', line 3

def overlap?(other)
  (first <= other.last) and (other.first <= last)
end