rangops 1.0.0.beta1 → 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +55 -27
- data/docs/README_md.html +45 -21
- data/docs/Rangops/Set.html +8 -7
- data/docs/created.rid +3 -3
- data/docs/index.html +45 -21
- data/docs/js/search_index.js +1 -1
- data/docs/js/search_index.js.gz +0 -0
- data/docs/table_of_contents.html +1 -1
- data/lib/rangops/set.rb +2 -1
- data/lib/rangops/version.rb +1 -1
- data/rangops.gemspec +7 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38a8f10cb6a5c045a2f06e1184724bc1c19ba47f25c16bf822a8f76bbd23cabe
|
|
4
|
+
data.tar.gz: f31fa31f633ee641fb295ec162b43c7cd43a1d5f83145f037f61dfcd97528c31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdbc3a6e057d03dece38ffd6145425b818ea8787344c098308a6d108b662ec524bf366970318706b83c5d77ecafb8d5a81a06d5c54d8b1c13fa391171f03f61b
|
|
7
|
+
data.tar.gz: 3ad54954874d3f78972ca63710b9ca90d26e3b6667dffcfc4db8c8a238f6967c972a432589cc56edddca33ec7d52b07cb39f89b910b4d7a909c06cf747a8b757
|
data/README.md
CHANGED
|
@@ -1,49 +1,77 @@
|
|
|
1
1
|
# Rangops
|
|
2
2
|
|
|
3
|
-
Rangops is a
|
|
3
|
+
Rangops is a tiny Ruby extension library that aims to treat Ranges as sets.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Install it with `gem install rangops` or add `gem "rangops"` to your Gemfile.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
end
|
|
7
|
+
It patches `Range` class with methods for basic set related operations
|
|
8
|
+
and predicates, like:
|
|
10
9
|
|
|
11
10
|
Union:
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
(1..5).union(3..10)
|
|
13
|
+
=> 1..10
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
(1..5) + (3..10)
|
|
16
|
+
=> 1..10
|
|
18
17
|
|
|
19
18
|
Intersection:
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
(1..5).intersection(3..10)
|
|
21
|
+
=> 3..5
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
(1..5) & (3..10)
|
|
24
|
+
=> 3..5
|
|
26
25
|
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
For full list of methods, check [API docs](https://bartpiet.github.io/rangops/).
|
|
27
|
+
Symmetric difference:
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Ranges delimited with any type of Numerics can be operated.
|
|
29
|
+
(1..10).difference(5..15)
|
|
30
|
+
=> [1..5, 10..15]
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
(1..10) - (5..15)
|
|
33
|
+
=> [1..5, 10..15]
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
not available if they only make sense for numbers.
|
|
35
|
+
Relative complement:
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
(1..10).complement(5..15)
|
|
38
|
+
=> 10..15
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
Check [API docs](https://bartpiet.github.io/rangops/) for full list of aliases
|
|
42
|
+
and predicates.
|
|
43
|
+
|
|
44
|
+
There is no mapping to arrays nor iteratons under the hood,
|
|
45
|
+
just begin/end values comparison - so operations on ranges of any size are
|
|
46
|
+
possible, with no penalty on speed or memory usage.
|
|
47
|
+
Ranges delimited with any type of Numerics can be used.
|
|
48
|
+
|
|
49
|
+
(1.0..10).union(Rational(20, 4)..Float::INFINITY)
|
|
50
|
+
=> 1.0..Infinity
|
|
51
|
+
|
|
52
|
+
Beginless and endless ranges are supported.
|
|
53
|
+
|
|
54
|
+
(nil..10).intersection(5..nil)
|
|
55
|
+
=> 5..10
|
|
56
|
+
|
|
57
|
+
(nil..10).union(5..nil)
|
|
58
|
+
=> nil..nil
|
|
59
|
+
|
|
60
|
+
It works well on string and date ranges too.
|
|
61
|
+
|
|
62
|
+
('2025-01-01'..'2026-12-31') & ('2026-01-01'..'2027-12-31')
|
|
63
|
+
=> '2026-01-01'..'2026-12-31'
|
|
64
|
+
|
|
65
|
+
('a'..'e') & ('c'..'g')
|
|
66
|
+
=> "c".."e"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Operations are supposed to return a `Range` result, so they only work on
|
|
70
|
+
arguments delimited with values of the same type.
|
|
71
|
+
`(1..5) & ('c'..'g')` will just return `nil`
|
|
45
72
|
|
|
46
73
|
|
|
47
74
|
## License
|
|
48
75
|
|
|
49
|
-
The gem is available as open source under the terms of the
|
|
76
|
+
The gem is available as open source under the terms of the
|
|
77
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/docs/README_md.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<title>README - Rangops</title>
|
|
9
9
|
|
|
10
10
|
<meta name="keywords" content="ruby,documentation,README">
|
|
11
|
-
<meta name="description" content="README: Rangops Rangops is a
|
|
11
|
+
<meta name="description" content="README: Rangops Rangops is a tiny Ruby extension library that aims to treat Ranges as sets. Install it with `gem install rangops` or add `gem "rangops"` to y">
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
<script type="text/javascript">
|
|
@@ -106,41 +106,65 @@
|
|
|
106
106
|
|
|
107
107
|
<h1 id="label-Rangops"><a href="Rangops.html"><code>Rangops</code></a><span><a href="#label-Rangops">¶</a> <a href="#top">↑</a></span></h1>
|
|
108
108
|
|
|
109
|
-
<p><a href="Rangops.html"><code>Rangops</code></a> is a
|
|
109
|
+
<p><a href="Rangops.html"><code>Rangops</code></a> is a tiny Ruby extension library that aims to treat Ranges as sets.</p>
|
|
110
110
|
|
|
111
|
-
<p>
|
|
111
|
+
<p>Install it with <code>gem install rangops</code> or add <code>gem "rangops"</code> to your Gemfile.</p>
|
|
112
112
|
|
|
113
|
-
<
|
|
114
|
-
<span class="ruby-identifier">include</span> <span class="ruby-constant">Rangops</span><span class="ruby-operator">::</span><span class="ruby-constant">Set</span>
|
|
115
|
-
<span class="ruby-keyword">end</span>
|
|
116
|
-
</pre>
|
|
113
|
+
<p>It patches <code>Range</code> class with methods for basic set related operations and predicates, like:</p>
|
|
117
114
|
|
|
118
115
|
<p>Union:</p>
|
|
119
116
|
|
|
120
|
-
<pre>
|
|
121
|
-
|
|
117
|
+
<pre>(1..5).union(3..10)
|
|
118
|
+
=> 1..10
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
(1..5) + (3..10)
|
|
121
|
+
=> 1..10</pre>
|
|
125
122
|
|
|
126
123
|
<p>Intersection:</p>
|
|
127
124
|
|
|
128
|
-
<pre>
|
|
129
|
-
|
|
125
|
+
<pre>(1..5).intersection(3..10)
|
|
126
|
+
=> 3..5
|
|
130
127
|
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
(1..5) & (3..10)
|
|
129
|
+
=> 3..5</pre>
|
|
133
130
|
|
|
134
|
-
<p>
|
|
131
|
+
<p>Symmetric difference:</p>
|
|
135
132
|
|
|
136
|
-
<
|
|
133
|
+
<pre>(1..10).difference(5..15)
|
|
134
|
+
=> [1..5, 10..15]
|
|
137
135
|
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
(1..10) - (5..15)
|
|
137
|
+
=> [1..5, 10..15]</pre>
|
|
140
138
|
|
|
141
|
-
<p>
|
|
139
|
+
<p>Relative complement:</p>
|
|
142
140
|
|
|
143
|
-
<
|
|
141
|
+
<pre>(1..10).complement(5..15)
|
|
142
|
+
=> 10..15</pre>
|
|
143
|
+
|
|
144
|
+
<p>Check <a href="https://bartpiet.github.io/rangops/">API docs</a> for full list of aliases and predicates.</p>
|
|
145
|
+
|
|
146
|
+
<p>There is no mapping to arrays nor iteratons under the hood, just begin/end values comparison - so operations on ranges of any size are possible, with no penalty on speed or memory usage. Ranges delimited with any type of Numerics can be used.</p>
|
|
147
|
+
|
|
148
|
+
<pre>(1.0..10).union(Rational(20, 4)..Float::INFINITY)
|
|
149
|
+
=> 1.0..Infinity</pre>
|
|
150
|
+
|
|
151
|
+
<p>Beginless and endless ranges are supported.</p>
|
|
152
|
+
|
|
153
|
+
<pre>(nil..10).intersection(5..nil)
|
|
154
|
+
=> 5..10
|
|
155
|
+
|
|
156
|
+
(nil..10).union(5..nil)
|
|
157
|
+
=> nil..nil</pre>
|
|
158
|
+
|
|
159
|
+
<p>It works well on string and date ranges too.</p>
|
|
160
|
+
|
|
161
|
+
<pre>('2025-01-01'..'2026-12-31') & ('2026-01-01'..'2027-12-31')
|
|
162
|
+
=> '2026-01-01'..'2026-12-31'
|
|
163
|
+
|
|
164
|
+
('a'..'e') & ('c'..'g')
|
|
165
|
+
=> "c".."e"</pre>
|
|
166
|
+
|
|
167
|
+
<p>Operations are supposed to return a <code>Range</code> result, so they only work on arguments delimited with values of the same type. <code>(1..5) & ('c'..'g')</code> will just return <code>nil</code></p>
|
|
144
168
|
|
|
145
169
|
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#top">↑</a></span></h2>
|
|
146
170
|
|
data/docs/Rangops/Set.html
CHANGED
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
|
|
184
184
|
<div class="method-description">
|
|
185
185
|
<div class="method-source-code" id="sort_by_boundaries-source">
|
|
186
|
-
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line
|
|
186
|
+
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line 176</span>
|
|
187
187
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">sort_by_boundaries</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>)
|
|
188
188
|
<span class="ruby-identifier">ary</span> = [<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>]
|
|
189
189
|
<span class="ruby-identifier">lower</span> = <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">find</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">begin</span>.<span class="ruby-identifier">nil?</span> } <span class="ruby-operator">||</span> <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">sort_by</span>(<span class="ruby-operator">&</span><span class="ruby-value">:begin</span>).<span class="ruby-identifier">first</span>
|
|
@@ -407,7 +407,7 @@
|
|
|
407
407
|
|
|
408
408
|
<div class="method-description">
|
|
409
409
|
<div class="method-source-code" id="disjoint-3F-source">
|
|
410
|
-
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line
|
|
410
|
+
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line 105</span>
|
|
411
411
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">disjoint?</span>(<span class="ruby-identifier">other</span>)
|
|
412
412
|
<span class="ruby-operator">!</span><span class="ruby-identifier">intersect?</span>(<span class="ruby-identifier">other</span>)
|
|
413
413
|
<span class="ruby-keyword">end</span></pre>
|
|
@@ -439,7 +439,8 @@
|
|
|
439
439
|
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line 97</span>
|
|
440
440
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">intersect?</span>(<span class="ruby-identifier">other</span>)
|
|
441
441
|
<span class="ruby-identifier">lower</span>, <span class="ruby-identifier">upper</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">sort_by_boundaries</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">other</span>)
|
|
442
|
-
<span class="ruby-identifier">lower</span>.<span class="ruby-identifier">cover?</span>(<span class="ruby-identifier">upper</span>.<span class="ruby-identifier">begin</span>) <span class="ruby-operator">||</span>
|
|
442
|
+
<span class="ruby-identifier">lower</span>.<span class="ruby-identifier">cover?</span>(<span class="ruby-identifier">upper</span>.<span class="ruby-identifier">begin</span>) <span class="ruby-operator">||</span>
|
|
443
|
+
(<span class="ruby-identifier">upper</span>.<span class="ruby-identifier">cover?</span>(<span class="ruby-identifier">lower</span>.<span class="ruby-identifier">end</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">lower</span>.<span class="ruby-identifier">exclude_end?</span>)
|
|
443
444
|
<span class="ruby-keyword">end</span></pre>
|
|
444
445
|
</div>
|
|
445
446
|
<p>Checks if 2 ranges have any common elements.</p>
|
|
@@ -535,7 +536,7 @@
|
|
|
535
536
|
|
|
536
537
|
<div class="method-description">
|
|
537
538
|
<div class="method-source-code" id="proper_subset-3F-source">
|
|
538
|
-
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line
|
|
539
|
+
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line 163</span>
|
|
539
540
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">proper_subset?</span>(<span class="ruby-identifier">other</span>)
|
|
540
541
|
<span class="ruby-identifier">subset?</span>(<span class="ruby-identifier">other</span>) <span class="ruby-operator">&&</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">other</span>
|
|
541
542
|
<span class="ruby-keyword">end</span></pre>
|
|
@@ -570,7 +571,7 @@
|
|
|
570
571
|
|
|
571
572
|
<div class="method-description">
|
|
572
573
|
<div class="method-source-code" id="proper_superset-3F-source">
|
|
573
|
-
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line
|
|
574
|
+
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line 134</span>
|
|
574
575
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">proper_superset?</span>(<span class="ruby-identifier">other</span>)
|
|
575
576
|
<span class="ruby-identifier">superset?</span>(<span class="ruby-identifier">other</span>) <span class="ruby-operator">&&</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">other</span>
|
|
576
577
|
<span class="ruby-keyword">end</span></pre>
|
|
@@ -605,7 +606,7 @@
|
|
|
605
606
|
|
|
606
607
|
<div class="method-description">
|
|
607
608
|
<div class="method-source-code" id="subset-3F-source">
|
|
608
|
-
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line
|
|
609
|
+
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line 149</span>
|
|
609
610
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">subset?</span>(<span class="ruby-identifier">other</span>)
|
|
610
611
|
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">superset?</span>(<span class="ruby-keyword">self</span>)
|
|
611
612
|
<span class="ruby-keyword">end</span></pre>
|
|
@@ -646,7 +647,7 @@
|
|
|
646
647
|
|
|
647
648
|
<div class="method-description">
|
|
648
649
|
<div class="method-source-code" id="superset-3F-source">
|
|
649
|
-
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line
|
|
650
|
+
<pre><span class="ruby-comment"># File lib/rangops/set.rb, line 120</span>
|
|
650
651
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">superset?</span>(<span class="ruby-identifier">other</span>)
|
|
651
652
|
<span class="ruby-identifier">cover?</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">begin</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">cover?</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">end</span>)
|
|
652
653
|
<span class="ruby-keyword">end</span></pre>
|
data/docs/created.rid
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
README.md Wed,
|
|
3
|
-
lib/rangops/set.rb
|
|
1
|
+
Wed, 13 Aug 2025 22:14:30 +0200
|
|
2
|
+
README.md Wed, 13 Aug 2025 22:13:55 +0200
|
|
3
|
+
lib/rangops/set.rb Wed, 13 Aug 2025 22:04:18 +0200
|
data/docs/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta name="keywords" content="ruby,documentation,Rangops">
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
<meta name="description" content="Rangops: Rangops Rangops is a
|
|
13
|
+
<meta name="description" content="Rangops: Rangops Rangops is a tiny Ruby extension library that aims to treat Ranges as sets. Install it with `gem install rangops` or add `gem "rangops"` to y">
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
<script type="text/javascript">
|
|
@@ -115,41 +115,65 @@
|
|
|
115
115
|
|
|
116
116
|
<h1 id="label-Rangops"><a href="Rangops.html"><code>Rangops</code></a><span><a href="#label-Rangops">¶</a> <a href="#top">↑</a></span></h1>
|
|
117
117
|
|
|
118
|
-
<p><a href="Rangops.html"><code>Rangops</code></a> is a
|
|
118
|
+
<p><a href="Rangops.html"><code>Rangops</code></a> is a tiny Ruby extension library that aims to treat Ranges as sets.</p>
|
|
119
119
|
|
|
120
|
-
<p>
|
|
120
|
+
<p>Install it with <code>gem install rangops</code> or add <code>gem "rangops"</code> to your Gemfile.</p>
|
|
121
121
|
|
|
122
|
-
<
|
|
123
|
-
<span class="ruby-identifier">include</span> <span class="ruby-constant">Rangops</span><span class="ruby-operator">::</span><span class="ruby-constant">Set</span>
|
|
124
|
-
<span class="ruby-keyword">end</span>
|
|
125
|
-
</pre>
|
|
122
|
+
<p>It patches <code>Range</code> class with methods for basic set related operations and predicates, like:</p>
|
|
126
123
|
|
|
127
124
|
<p>Union:</p>
|
|
128
125
|
|
|
129
|
-
<pre>
|
|
130
|
-
|
|
126
|
+
<pre>(1..5).union(3..10)
|
|
127
|
+
=> 1..10
|
|
131
128
|
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
(1..5) + (3..10)
|
|
130
|
+
=> 1..10</pre>
|
|
134
131
|
|
|
135
132
|
<p>Intersection:</p>
|
|
136
133
|
|
|
137
|
-
<pre>
|
|
138
|
-
|
|
134
|
+
<pre>(1..5).intersection(3..10)
|
|
135
|
+
=> 3..5
|
|
139
136
|
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
(1..5) & (3..10)
|
|
138
|
+
=> 3..5</pre>
|
|
142
139
|
|
|
143
|
-
<p>
|
|
140
|
+
<p>Symmetric difference:</p>
|
|
144
141
|
|
|
145
|
-
<
|
|
142
|
+
<pre>(1..10).difference(5..15)
|
|
143
|
+
=> [1..5, 10..15]
|
|
146
144
|
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
(1..10) - (5..15)
|
|
146
|
+
=> [1..5, 10..15]</pre>
|
|
149
147
|
|
|
150
|
-
<p>
|
|
148
|
+
<p>Relative complement:</p>
|
|
151
149
|
|
|
152
|
-
<
|
|
150
|
+
<pre>(1..10).complement(5..15)
|
|
151
|
+
=> 10..15</pre>
|
|
152
|
+
|
|
153
|
+
<p>Check <a href="https://bartpiet.github.io/rangops/">API docs</a> for full list of aliases and predicates.</p>
|
|
154
|
+
|
|
155
|
+
<p>There is no mapping to arrays nor iteratons under the hood, just begin/end values comparison - so operations on ranges of any size are possible, with no penalty on speed or memory usage. Ranges delimited with any type of Numerics can be used.</p>
|
|
156
|
+
|
|
157
|
+
<pre>(1.0..10).union(Rational(20, 4)..Float::INFINITY)
|
|
158
|
+
=> 1.0..Infinity</pre>
|
|
159
|
+
|
|
160
|
+
<p>Beginless and endless ranges are supported.</p>
|
|
161
|
+
|
|
162
|
+
<pre>(nil..10).intersection(5..nil)
|
|
163
|
+
=> 5..10
|
|
164
|
+
|
|
165
|
+
(nil..10).union(5..nil)
|
|
166
|
+
=> nil..nil</pre>
|
|
167
|
+
|
|
168
|
+
<p>It works well on string and date ranges too.</p>
|
|
169
|
+
|
|
170
|
+
<pre>('2025-01-01'..'2026-12-31') & ('2026-01-01'..'2027-12-31')
|
|
171
|
+
=> '2026-01-01'..'2026-12-31'
|
|
172
|
+
|
|
173
|
+
('a'..'e') & ('c'..'g')
|
|
174
|
+
=> "c".."e"</pre>
|
|
175
|
+
|
|
176
|
+
<p>Operations are supposed to return a <code>Range</code> result, so they only work on arguments delimited with values of the same type. <code>(1..5) & ('c'..'g')</code> will just return <code>nil</code></p>
|
|
153
177
|
|
|
154
178
|
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#top">↑</a></span></h2>
|
|
155
179
|
|
data/docs/js/search_index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var search_data = {"index":{"searchIndex":["rangops","set","&()","+()","-()","complement()","contains?()","difference()","disjoint?()","intersect?()","intersection()","is_contained_by?()","proper_subset?()","proper_superset?()","sort_by_boundaries()","subset?()","superset?()","union()","|()","readme"],"longSearchIndex":["rangops","rangops::set","rangops::set#&()","rangops::set#+()","rangops::set#-()","rangops::set#complement()","rangops::set#contains?()","rangops::set#difference()","rangops::set#disjoint?()","rangops::set#intersect?()","rangops::set#intersection()","rangops::set#is_contained_by?()","rangops::set#proper_subset?()","rangops::set#proper_superset?()","rangops::set::sort_by_boundaries()","rangops::set#subset?()","rangops::set#superset?()","rangops::set#union()","rangops::set#|()",""],"info":[["Rangops","","Rangops.html","",""],["Rangops::Set","","Rangops/Set.html","","<p>Module defining basic set operations that can be performed\non ranges.\n<p>union\n<p>intersection\n"],["&","Rangops::Set","Rangops/Set.html#method-i-26","(other)",""],["+","Rangops::Set","Rangops/Set.html#method-i-2B","(other)",""],["-","Rangops::Set","Rangops/Set.html#method-i-2D","(other)",""],["complement","Rangops::Set","Rangops/Set.html#method-i-complement","(other)","<p>Relative complement of 2 ranges. Returns a range covering\nelements from <code>other</code> that are not covered by ...\n"],["contains?","Rangops::Set","Rangops/Set.html#method-i-contains-3F","(other)",""],["difference","Rangops::Set","Rangops/Set.html#method-i-difference","(other)","<p>Symmetric difference of 2 ranges. Returns ranges covering\nelements of both operands, excluding elements ...\n"],["disjoint?","Rangops::Set","Rangops/Set.html#method-i-disjoint-3F","(other)","<p>Opposite of ‘intersect?.\n"],["intersect?","Rangops::Set","Rangops/Set.html#method-i-intersect-3F","(other)","<p>Checks if 2 ranges have any common elements.\n\n<pre> (1..10).intersect?(8..15)\n => true\n\n (1..10).intersect?(11..15) ...</pre>\n"],["intersection","Rangops::Set","Rangops/Set.html#method-i-intersection","(other)","<p>Intersection of 2 ranges. Returns a range covering elements\ncommon to both ranges. Returns <code>nil</code> if ranges ...\n"],["is_contained_by?","Rangops::Set","Rangops/Set.html#method-i-is_contained_by-3F","(other)",""],["proper_subset?","Rangops::Set","Rangops/Set.html#method-i-proper_subset-3F","(other)","<p>Checks if <code>self</code> is proper subset of <code>other</code>,\ni.e. is subset and has elements not present\nin <code>other</code>.\n\n<pre class=\"ruby\">(<span class=\"ruby-value\">1</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">10</span>).<span class=\"ruby-identifier\">proper_subset?</span>(<span class=\"ruby-value\">0</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">12</span>) <span class=\"ruby-operator\">...</span>\n</pre>\n"],["proper_superset?","Rangops::Set","Rangops/Set.html#method-i-proper_superset-3F","(other)","<p>Checks if <code>self</code> is proper superset of <code>other</code>,\ni.e. is superset and has elements not present\nin <code>other</code>.\n\n<pre class=\"ruby\">(<span class=\"ruby-value\">1</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">10</span>).<span class=\"ruby-identifier\">proper_superset?</span>(<span class=\"ruby-value\">2</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">5</span>) <span class=\"ruby-operator\">...</span>\n</pre>\n"],["sort_by_boundaries","Rangops::Set","Rangops/Set.html#method-c-sort_by_boundaries","(a, b)","<p>Determine which range has lower begin, and which one higher end.\n"],["subset?","Rangops::Set","Rangops/Set.html#method-i-subset-3F","(other)","<p>Checks if <code>self</code> is subset of <code>other</code>, i.e. all\nelements of <code>self</code> fit within <code>other</code>.\n\n<pre class=\"ruby\">(<span class=\"ruby-value\">1</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">10</span>).<span class=\"ruby-identifier\">subset?</span>(<span class=\"ruby-value\">0</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">12</span>) <span class=\"ruby-operator\">...</span>\n</pre>\n"],["superset?","Rangops::Set","Rangops/Set.html#method-i-superset-3F","(other)","<p>Checks if <code>self</code> is superset of <code>other</code>, i.e. all\nelements of <code>other</code> fit within <code>self</code>.\n\n<pre class=\"ruby\">(<span class=\"ruby-value\">1</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">10</span>).<span class=\"ruby-identifier\">superset?</span>(<span class=\"ruby-value\">2</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">5</span>) <span class=\"ruby-operator\">...</span>\n</pre>\n"],["union","Rangops::Set","Rangops/Set.html#method-i-union","(other)","<p>Union of 2 ranges. Returns a range covering sum of all elements\nbelonging to both ranges. Returns <code>nil</code> ...\n"],["|","Rangops::Set","Rangops/Set.html#method-i-7C","(other)",""],["README","","README_md.html","","<p>Rangops\n<p>Rangops is a
|
|
1
|
+
var search_data = {"index":{"searchIndex":["rangops","set","&()","+()","-()","complement()","contains?()","difference()","disjoint?()","intersect?()","intersection()","is_contained_by?()","proper_subset?()","proper_superset?()","sort_by_boundaries()","subset?()","superset?()","union()","|()","readme"],"longSearchIndex":["rangops","rangops::set","rangops::set#&()","rangops::set#+()","rangops::set#-()","rangops::set#complement()","rangops::set#contains?()","rangops::set#difference()","rangops::set#disjoint?()","rangops::set#intersect?()","rangops::set#intersection()","rangops::set#is_contained_by?()","rangops::set#proper_subset?()","rangops::set#proper_superset?()","rangops::set::sort_by_boundaries()","rangops::set#subset?()","rangops::set#superset?()","rangops::set#union()","rangops::set#|()",""],"info":[["Rangops","","Rangops.html","",""],["Rangops::Set","","Rangops/Set.html","","<p>Module defining basic set operations that can be performed\non ranges.\n<p>union\n<p>intersection\n"],["&","Rangops::Set","Rangops/Set.html#method-i-26","(other)",""],["+","Rangops::Set","Rangops/Set.html#method-i-2B","(other)",""],["-","Rangops::Set","Rangops/Set.html#method-i-2D","(other)",""],["complement","Rangops::Set","Rangops/Set.html#method-i-complement","(other)","<p>Relative complement of 2 ranges. Returns a range covering\nelements from <code>other</code> that are not covered by ...\n"],["contains?","Rangops::Set","Rangops/Set.html#method-i-contains-3F","(other)",""],["difference","Rangops::Set","Rangops/Set.html#method-i-difference","(other)","<p>Symmetric difference of 2 ranges. Returns ranges covering\nelements of both operands, excluding elements ...\n"],["disjoint?","Rangops::Set","Rangops/Set.html#method-i-disjoint-3F","(other)","<p>Opposite of ‘intersect?.\n"],["intersect?","Rangops::Set","Rangops/Set.html#method-i-intersect-3F","(other)","<p>Checks if 2 ranges have any common elements.\n\n<pre> (1..10).intersect?(8..15)\n => true\n\n (1..10).intersect?(11..15) ...</pre>\n"],["intersection","Rangops::Set","Rangops/Set.html#method-i-intersection","(other)","<p>Intersection of 2 ranges. Returns a range covering elements\ncommon to both ranges. Returns <code>nil</code> if ranges ...\n"],["is_contained_by?","Rangops::Set","Rangops/Set.html#method-i-is_contained_by-3F","(other)",""],["proper_subset?","Rangops::Set","Rangops/Set.html#method-i-proper_subset-3F","(other)","<p>Checks if <code>self</code> is proper subset of <code>other</code>,\ni.e. is subset and has elements not present\nin <code>other</code>.\n\n<pre class=\"ruby\">(<span class=\"ruby-value\">1</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">10</span>).<span class=\"ruby-identifier\">proper_subset?</span>(<span class=\"ruby-value\">0</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">12</span>) <span class=\"ruby-operator\">...</span>\n</pre>\n"],["proper_superset?","Rangops::Set","Rangops/Set.html#method-i-proper_superset-3F","(other)","<p>Checks if <code>self</code> is proper superset of <code>other</code>,\ni.e. is superset and has elements not present\nin <code>other</code>.\n\n<pre class=\"ruby\">(<span class=\"ruby-value\">1</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">10</span>).<span class=\"ruby-identifier\">proper_superset?</span>(<span class=\"ruby-value\">2</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">5</span>) <span class=\"ruby-operator\">...</span>\n</pre>\n"],["sort_by_boundaries","Rangops::Set","Rangops/Set.html#method-c-sort_by_boundaries","(a, b)","<p>Determine which range has lower begin, and which one higher end.\n"],["subset?","Rangops::Set","Rangops/Set.html#method-i-subset-3F","(other)","<p>Checks if <code>self</code> is subset of <code>other</code>, i.e. all\nelements of <code>self</code> fit within <code>other</code>.\n\n<pre class=\"ruby\">(<span class=\"ruby-value\">1</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">10</span>).<span class=\"ruby-identifier\">subset?</span>(<span class=\"ruby-value\">0</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">12</span>) <span class=\"ruby-operator\">...</span>\n</pre>\n"],["superset?","Rangops::Set","Rangops/Set.html#method-i-superset-3F","(other)","<p>Checks if <code>self</code> is superset of <code>other</code>, i.e. all\nelements of <code>other</code> fit within <code>self</code>.\n\n<pre class=\"ruby\">(<span class=\"ruby-value\">1</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">10</span>).<span class=\"ruby-identifier\">superset?</span>(<span class=\"ruby-value\">2</span><span class=\"ruby-operator\">..</span><span class=\"ruby-value\">5</span>) <span class=\"ruby-operator\">...</span>\n</pre>\n"],["union","Rangops::Set","Rangops/Set.html#method-i-union","(other)","<p>Union of 2 ranges. Returns a range covering sum of all elements\nbelonging to both ranges. Returns <code>nil</code> ...\n"],["|","Rangops::Set","Rangops/Set.html#method-i-7C","(other)",""],["README","","README_md.html","","<p>Rangops\n<p>Rangops is a tiny Ruby extension library that aims to treat Ranges as sets.\n<p>Install it with <code>gem</code> …\n"]]}}
|
data/docs/js/search_index.js.gz
CHANGED
|
Binary file
|
data/docs/table_of_contents.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<meta name="keywords" content="ruby,documentation,Table of Contents - Rangops">
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
<meta name="description" content="Table of Contents - Rangops: Rangops Rangops is a
|
|
13
|
+
<meta name="description" content="Table of Contents - Rangops: Rangops Rangops is a tiny Ruby extension library that aims to treat Ranges as sets. Install it with `gem install rangops` or add `gem "rangops"` to y">
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
<script type="text/javascript">
|
data/lib/rangops/set.rb
CHANGED
|
@@ -96,7 +96,8 @@ module Rangops
|
|
|
96
96
|
# => false
|
|
97
97
|
def intersect?(other)
|
|
98
98
|
lower, upper = Set.sort_by_boundaries(self, other)
|
|
99
|
-
lower.cover?(upper.begin) ||
|
|
99
|
+
lower.cover?(upper.begin) ||
|
|
100
|
+
(upper.cover?(lower.end) && !lower.exclude_end?)
|
|
100
101
|
end
|
|
101
102
|
|
|
102
103
|
|
data/lib/rangops/version.rb
CHANGED
data/rangops.gemspec
CHANGED
|
@@ -13,6 +13,13 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.homepage = "https://bartpiet.github.io/rangops/"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
|
+
spec.metadata = {
|
|
17
|
+
"bug_tracker_uri" => "https://github.com/bartpiet/rangops/issues",
|
|
18
|
+
"documentation_uri" => "https://bartpiet.github.io/rangops/",
|
|
19
|
+
"homepage_uri" => "https://github.com/bartpiet/rangops",
|
|
20
|
+
"source_code_uri" => "https://github.com/bartpiet/rangops",
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
24
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
25
|
if spec.respond_to?(:metadata)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rangops
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.0.
|
|
4
|
+
version: 1.0.0.rc1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bartosz Pietraszko
|
|
@@ -120,6 +120,10 @@ homepage: https://bartpiet.github.io/rangops/
|
|
|
120
120
|
licenses:
|
|
121
121
|
- MIT
|
|
122
122
|
metadata:
|
|
123
|
+
bug_tracker_uri: https://github.com/bartpiet/rangops/issues
|
|
124
|
+
documentation_uri: https://bartpiet.github.io/rangops/
|
|
125
|
+
homepage_uri: https://github.com/bartpiet/rangops
|
|
126
|
+
source_code_uri: https://github.com/bartpiet/rangops
|
|
123
127
|
allowed_push_host: https://rubygems.org
|
|
124
128
|
rdoc_options: []
|
|
125
129
|
require_paths:
|