Class: Range
Instance Method Summary collapse
-
#last_element ⇒ Object
(1..2).last_element == 2 (1…3).last_element == 2.
-
#move(n) ⇒ Object
(1..2).move(2) == (3..4).
- #overlap?(other) ⇒ Boolean
Instance Method Details
#last_element ⇒ Object
(1..2).last_element == 2 (1…3).last_element == 2
9 10 11 |
# File 'lib/ruco/core_ext/range.rb', line 9 def last_element Dispel::Tools.last_element(self) end |
#move(n) ⇒ Object
(1..2).move(2) == (3..4)
14 15 16 17 18 19 20 |
# File 'lib/ruco/core_ext/range.rb', line 14 def move(n) if exclude_end? (first + n)...(last + n) else (first + n)..(last + n) end end |
#overlap?(other) ⇒ Boolean
3 4 5 |
# File 'lib/ruco/core_ext/range.rb', line 3 def overlap?(other) (first <= other.last) and (other.first <= last) end |