README.md in multi_range-1.1.0 vs README.md in multi_range-1.2.0
- old
+ new
@@ -23,20 +23,20 @@
$ gem install multi_range
## Usage
-Allow you to manipulate a group of ranges.
+Allow you to manipulate a group of ranges. Such as merging overlapping ranges, doing ranges union and difference.
### Sample a number
```rb
multi_range = MultiRange.new([1..5, 10..12])
multi_range.sample
# => equals to [1, 2, 3, 4, 5, 10, 11, 12].sample
```
-### Range difference
+### Difference of ranges
```rb
multi_range = MultiRange.new([1..10])
multi_range -= 5..7
multi_range.ranges
# => [1...5, 8..10]
@@ -54,11 +54,11 @@
multi_range -= MultiRange.new([5..60, 75..85])
multi_range.ranges
# => [1...5, 61..70, 86..100]
```
-### Range union
+### Union ranges
```rb
multi_range = MultiRange.new([1..5])
multi_range |= 3..8
multi_range.ranges
@@ -70,17 +70,21 @@
multi_range |= MultiRange.new([3..6, 14..22, 30])
multi_range.ranges
# => [1..6, 10..25, 30..30]
```
-### Flatten
+### Merge overlaps
```rb
multi_range = MultiRange.new([1, 2, 4..6, 7, 8..12])
multi_range.merge_overlaps.ranges
# => [1..2, 4..12]
+
+multi_range = MultiRange.new([1.2..1.5, 1.7..1.9, 1.8..2.2])
+multi_range.merge_overlaps.ranges
+# => [1.2..1.5, 1.7..2.2]
```
-### Overlaps?
+### Check if it overlaps with the other
```rb
multi_range = MultiRange.new([1..5, 10..15, 20..25])
multi_range.overlaps?(7..8)
# => false