rmtools 1.3.2 → 1.3.3
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.
- data/README.md +5 -3
- data/Rakefile +1 -1
- data/lib/rmtools/enumerable/range.rb +24 -5
- metadata +1 -1
data/README.md
CHANGED
@@ -23,13 +23,15 @@ It's still randomly documented since it's just my working tool.
|
|
23
23
|
|
24
24
|
### CHANGES
|
25
25
|
|
26
|
-
##### Version 1.3.
|
26
|
+
##### Version 1.3.3
|
27
27
|
|
28
28
|
* Added to Array: #sort_along_by, #indices_map, #each_two
|
29
29
|
* Enumerable#map_hash
|
30
30
|
* Range
|
31
|
-
* * Fixed
|
32
|
-
* *
|
31
|
+
* * Fixed #size for backward ranges
|
32
|
+
* * Fixed #x? and #-@ for neighbor numbers and non-integers in general
|
33
|
+
* * added XRange#x?
|
34
|
+
* * aliased #x? as #intersects?
|
33
35
|
* Class#__init__ accepts block, auto__init__ed Thread and Proc
|
34
36
|
|
35
37
|
##### Version 1.3.0
|
data/Rakefile
CHANGED
@@ -5,6 +5,19 @@ end
|
|
5
5
|
|
6
6
|
class Range
|
7
7
|
|
8
|
+
# -(1.0..2.0)
|
9
|
+
### => XRange(-∞..1.0, 2.0..∞)
|
10
|
+
# BUT
|
11
|
+
# -(1..2)
|
12
|
+
### => XRange(-∞..0, 3..∞)
|
13
|
+
# i.e. all excluding these: (0; 1], [1; 2], [2; 3)
|
14
|
+
def -@
|
15
|
+
self_begin = self.begin
|
16
|
+
self_begin -= 1 if Integer === self_begin
|
17
|
+
self_end = include_end.end
|
18
|
+
self_end += 1 if Integer === self_end
|
19
|
+
XRange(-Inf..self_begin, self_end..Inf)
|
20
|
+
end
|
8
21
|
def &(range)
|
9
22
|
return range&self if range.is XRange
|
10
23
|
beg = [self.begin, range.begin].max
|
@@ -20,10 +33,16 @@ class Range
|
|
20
33
|
[self.begin, range.begin].min..[self_.end, range.end].max
|
21
34
|
end
|
22
35
|
|
23
|
-
def -@
|
24
|
-
XRange(-Inf..self.begin-1, include_end.end+1..Inf)
|
25
|
-
end
|
26
36
|
|
37
|
+
# On the basis of #-@ for non-integers,
|
38
|
+
# (0..1) - (1..2)
|
39
|
+
### => XRange(0..0)
|
40
|
+
# (0..1.0) - (1..2)
|
41
|
+
### => XRange(0..0)
|
42
|
+
# (0..1) - (1.0..2)
|
43
|
+
### => XRange(0..1.0)
|
44
|
+
# (0..1.0) - (1.0..2)
|
45
|
+
### => XRange(0..1.0)
|
27
46
|
def -(range)
|
28
47
|
self & -range
|
29
48
|
end
|
@@ -41,13 +60,13 @@ class Range
|
|
41
60
|
range_end = range.include_end.end
|
42
61
|
self_end = self.include_end.end
|
43
62
|
if self_end < range_end
|
44
|
-
if self_end
|
63
|
+
if Integer === self_end and Integer === range.begin
|
45
64
|
self_end >= range.begin
|
46
65
|
else
|
47
66
|
self_end > range.begin
|
48
67
|
end
|
49
68
|
else
|
50
|
-
if self.begin
|
69
|
+
if Integer === self.begin and Integer === range_end
|
51
70
|
range_end >= self.begin
|
52
71
|
else
|
53
72
|
range_end > self.begin
|