better_ranges 1.1.0 → 1.1.1
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/lib/better_ranges/range_operators.rb +1 -0
- data/lib/better_ranges/sparse_range.rb +7 -0
- data/lib/better_ranges/version.rb +1 -1
- data/spec/sparse_range_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62d2b490dbe53332a036fd6be51bd95f91b60602
|
4
|
+
data.tar.gz: 66cc985c6891427691f973079eca51c0599742b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba081c6e3883e3a6880f2f96e1c6ada0be0fe808811e6b43ebfdb4918ba7b0e4bd0c58e6d6d9d6a6481e6e66dde34968e3414f4dfec374be7f6395ca33161b90
|
7
|
+
data.tar.gz: 4708086e998060c9e631e20a2a632be0d2bcae48dd4ad0a5b7a0c27de8b174a3788d99aaa5319ab05705f33a5298f62a4b0f7ca580a24ddfd16d0c7cbe05961d
|
@@ -21,6 +21,12 @@ module BetterRanges
|
|
21
21
|
end.each(&block)
|
22
22
|
end
|
23
23
|
|
24
|
+
def sparse_each(&block)
|
25
|
+
@data.each do |x|
|
26
|
+
x.is_a?(Range) ? x : (x..x)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
def step(num = 1, &block)
|
25
31
|
i = 0
|
26
32
|
Enumerator.new do |yielder|
|
@@ -160,6 +166,7 @@ module BetterRanges
|
|
160
166
|
alias_method :union, :|
|
161
167
|
|
162
168
|
alias_method :minus, :-
|
169
|
+
alias_method :difference, :-
|
163
170
|
alias_method :intersect, :&
|
164
171
|
|
165
172
|
alias_method :add, :<<
|
data/spec/sparse_range_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
include BetterRanges
|
3
3
|
|
4
4
|
describe BetterRanges::SparseRange do
|
5
|
-
context '
|
5
|
+
context 'difference(#-)' do
|
6
6
|
it 'should work' do
|
7
7
|
a = SparseRange.new(-20..-10, 1..25, 50..75, 100..200, 300..400, 500..600, 700..800, 900)
|
8
8
|
b = SparseRange.new(-5..-1, 5..15, 40..80, 90..125, 150..225, 250..350, 550..650, 750, 850..950, 1000)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_ranges
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Ziminsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|