|
|
|
Ruby `Range` extensions. In order to comply with new features related to date/time ranges, a couple of new methods/operations are now introduced on the original [`Range`](https://ruby-doc.org/core-2.5.1/Range.html) class.
|
|
|
|
|
|
|
|
# Methods Provided
|
|
|
|
|
|
|
|
### `&` or `intersection`
|
|
|
|
|
|
|
|
A way to get the intersection between 2 ranges, just like: `(5..15) & (10..20) === (10..15)`. See the examples:
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
### `|` or `union`
|
|
|
|
|
|
|
|
A way to concatenate 2 ranges, regardless if they intersect or not. It basically gets the lowest and highest values. Like: `(5..15) | (10..20) === (5..20)`. See the examples:
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
### `-` or `subtract`
|
|
|
|
|
|
|
|
A way to remove the intersection portion of the left side range of the operation. Like: `(5..15) - (10..20) === (5..10)`. Non-intersecting ranges have no effect whatsoever. See the examples:
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
### `+` or `add`
|
|
|
|
|
|
|
|
A way to connect or add the extra portion of the right side range into the left side range. Like: `(5..15) + (10..20) === (5..20)`. Non-intersecting ranges have no effect whatsoever. See the examples:
|
|
|
|
|
|
|
|
 |
|
|
|
\ No newline at end of file |