multi_range 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82aa8d60271246bff1316449278536578153d944fd33bb8c1247175c055d98c4
4
- data.tar.gz: bac913e6497fc532f69a5a4dfca6066b9856b5ab82f80279a9d3669013a5620d
3
+ metadata.gz: 282c94c92ba01c11fb4e1efb2adc24ebe368d466660bd741878023bd1fb9c857
4
+ data.tar.gz: 2eb44495bac41d991ad6c29049b8f97395c848401e00ea96161ea0d101bb78ed
5
5
  SHA512:
6
- metadata.gz: 99c502e9fb9998ef235af41f696cdb41cdfb0559ed4431baff0b28e4873564c1c44e60c86638a7f72ff3f1f247b41effb807defb83aa1c91ed56225ff46f70f4
7
- data.tar.gz: 4804d00e47dbaec3c2f1a5013489fcd4a4a2f86204419176676b7c11e88c4fa9114c9f13956ad8c2e491a05619813af2f1de923eb334edec2b0a370a145d55a1
6
+ metadata.gz: 1c6bda5d61296f7aaf9dbb743477119b01a037be1085a7df85178340c97096fb8629b7cf384f4163d55177cd20be12b28b04b9fb48240c85dd6d5f5495612984
7
+ data.tar.gz: f23bf8796b02954a7b4724bf96b9bbe6779e284b70a563e4042996c97a62387125d120be5f6b1a451b1c7f982a20395774e7067544b4e7cb591785f096d49c4e
@@ -1,5 +1,12 @@
1
1
  ## Change Log
2
2
 
3
+ ### [v1.0.0](https://github.com/khiav223577/multi_range/compare/v0.0.4...v1.0.0) 2020/10/15
4
+ - [#12](https://github.com/khiav223577/multi_range/pull/12) Implement #overlaps? (@khiav223577)
5
+ - [#11](https://github.com/khiav223577/multi_range/pull/11) Support difference other multi_range object (@khiav223577)
6
+ - [#10](https://github.com/khiav223577/multi_range/pull/10) Add frozen_string_literal (@khiav223577)
7
+ - [#9](https://github.com/khiav223577/multi_range/pull/9) Implement range union (@khiav223577)
8
+ - [#8](https://github.com/khiav223577/multi_range/pull/8) Support initializing a MultiRange object with unsorted ranges (@khiav223577)
9
+
3
10
  ### [v0.0.4](https://github.com/khiav223577/multi_range/compare/v0.0.3...v0.0.4) 2020/03/26
4
11
  - [#7](https://github.com/khiav223577/multi_range/pull/7) Add flatten method (@khiav223577)
5
12
 
@@ -11,6 +18,6 @@
11
18
  - [#4](https://github.com/khiav223577/multi_range/pull/4) Add each, map, index_with methods (@khiav223577)
12
19
  - [#3](https://github.com/khiav223577/multi_range/pull/3) Support passing integer as range (@khiav223577)
13
20
 
14
- ### v0.0.1 2020/03/01
21
+ ### [v0.0.1](https://github.com/khiav223577/multi_range/compare/v0.0.1...v0.0.1) 2020/03/01
15
22
  - [#2](https://github.com/khiav223577/multi_range/pull/2) Support Ruby 1.8.7 (@khiav223577)
16
23
  - [#1](https://github.com/khiav223577/multi_range/pull/1) Implement MultiRange (@khiav223577)
data/README.md CHANGED
@@ -75,7 +75,7 @@ multi_range.ranges
75
75
  ### Flatten
76
76
  ```rb
77
77
  multi_range = MultiRange.new([1, 2, 4..6, 7, 8..12])
78
- multi_range.flatten.ranges
78
+ multi_range.merge_overlaps.ranges
79
79
  # => [1..2, 4..12]
80
80
  ```
81
81
 
@@ -147,13 +147,13 @@ MultiRange.new([1..3, 6, 8..9]).size
147
147
  ### Warning
148
148
 
149
149
  The return value may be different when there are some overlapped ranges.
150
- Call `flatten` if you want to merge overlapped ranges.
150
+ Call `merge_overlaps` if you want to merge overlapped ranges.
151
151
 
152
152
  ```rb
153
153
  MultiRange.new([1..5, 3..6]).to_a
154
154
  # => [1, 2, 3, 4, 5, 3, 4, 5, 6]
155
155
 
156
- MultiRange.new([1..5, 3..6]).flatten.to_a
156
+ MultiRange.new([1..5, 3..6]).merge_overlaps.to_a
157
157
  # => [1, 2, 3, 4, 5, 6]
158
158
  ```
159
159
 
@@ -161,7 +161,7 @@ MultiRange.new([1..5, 3..6]).flatten.to_a
161
161
  MultiRange.new([1..5, 3..6]).each{|s| print s }
162
162
  # => 123453456
163
163
 
164
- MultiRange.new([1..5, 3..6]).flatten.each{|s| print s }
164
+ MultiRange.new([1..5, 3..6]).merge_overlaps.each{|s| print s }
165
165
  # => 123456
166
166
  ```
167
167
 
@@ -169,7 +169,7 @@ MultiRange.new([1..5, 3..6]).flatten.each{|s| print s }
169
169
  MultiRange.new([1..5, 3..6]).map{|s| s * 2 }
170
170
  # => [2, 4, 6, 8, 10, 6, 8, 10, 12]
171
171
 
172
- MultiRange.new([1..5, 3..6]).flatten.map{|s| s * 2 }
172
+ MultiRange.new([1..5, 3..6]).merge_overlaps.map{|s| s * 2 }
173
173
  # => [2, 4, 6, 8, 10, 12]
174
174
  ```
175
175
 
@@ -177,7 +177,7 @@ MultiRange.new([1..5, 3..6]).flatten.map{|s| s * 2 }
177
177
  MultiRange.new([1..5, 3..6]).size
178
178
  # => 9
179
179
 
180
- MultiRange.new([1..5, 3..6]).flatten.size
180
+ MultiRange.new([1..5, 3..6]).merge_overlaps.size
181
181
  # => 6
182
182
  ```
183
183
 
@@ -25,7 +25,7 @@ class MultiRange
25
25
  @ranges = ranges.map{|s| s.is_a?(Integer) ? s..s : s }.sort_by(&:begin).freeze
26
26
  end
27
27
 
28
- def flatten
28
+ def merge_overlaps
29
29
  return MultiRange.new([]) if @ranges.size == 0
30
30
 
31
31
  new_ranges = []
@@ -82,11 +82,11 @@ class MultiRange
82
82
 
83
83
  def |(other)
84
84
  other_ranges = other.is_a?(MultiRange) ? other.ranges : [other]
85
- return MultiRange.new(@ranges + other_ranges).flatten
85
+ return MultiRange.new(@ranges + other_ranges).merge_overlaps
86
86
  end
87
87
 
88
88
  def overlaps?(other)
89
- multi_range = flatten
89
+ multi_range = merge_overlaps
90
90
  return multi_range.size != (multi_range - other).size
91
91
  end
92
92
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class MultiRange
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_range
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - khiav reoy