increments 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/increments.rb +14 -16
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4437c3349327b61ddf3322fa91021884c41a74ec
|
4
|
+
data.tar.gz: 32cc783207051d6e182bb19e87cb5363f19af790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b133d45ae339118c93eed809d33b2531ef270683bebae6be11741a5ae972a8877e626777e0e6cf4f62f43d4ef4ee8c7f4afbf8cb2dc5ccc6c34bee6d3e1cc463
|
7
|
+
data.tar.gz: 9a37e1eab9e100a04c79ee1db4f7925a2bfc9e51fafec09a8728ce5b663181a93ce3dabfec37c22a23e333af43177233f7724bab28ceb57a7fcb65942ae2f610
|
data/lib/increments.rb
CHANGED
@@ -3,10 +3,10 @@ module Increments
|
|
3
3
|
options = defaults.merge(opts)
|
4
4
|
validate(options)
|
5
5
|
min, max = options[:min], [options[:min] + options[:increment]-1, options[:max]].min
|
6
|
-
|
6
|
+
loop do
|
7
7
|
yield(min,max)
|
8
8
|
break if max == options[:max]
|
9
|
-
min = [min + options[:increment], options[:max]].min
|
9
|
+
min = [min + options[:increment], options[:max]].min
|
10
10
|
max = [max + options[:increment], options[:max]].min
|
11
11
|
end
|
12
12
|
end
|
@@ -15,7 +15,7 @@ module Increments
|
|
15
15
|
options = defaults.merge(opts)
|
16
16
|
validate(options)
|
17
17
|
min, max = [options[:min], options[:max] - options[:increment]+1].max, options[:max]
|
18
|
-
|
18
|
+
loop do
|
19
19
|
yield(min,max)
|
20
20
|
break if min == options[:min]
|
21
21
|
min = [min - options[:increment], options[:min]].max
|
@@ -23,19 +23,17 @@ module Increments
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
{
|
28
|
-
:min => 0,
|
29
|
-
:max => 4294967295,
|
30
|
-
:increment => 100000
|
31
|
-
}
|
32
|
-
end
|
26
|
+
private
|
33
27
|
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
def self.defaults
|
29
|
+
{
|
30
|
+
:min => 0,
|
31
|
+
:max => 4294967295,
|
32
|
+
:increment => 100000
|
33
|
+
}
|
34
|
+
end
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
def self.validate(options)
|
37
|
+
raise ArgumentError, "Invalid Options: #{options}" if options[:min] > options[:max] || options[:increment] <= 0
|
38
|
+
end
|
41
39
|
end
|
metadata
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: increments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garren Staubli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: Range bound incrementing and decrementing by a specified amount
|
14
14
|
email: gstaubli@demandbase.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/increments.rb
|
20
|
-
homepage:
|
20
|
+
homepage: https://github.com/gstaubli/increments
|
21
21
|
licenses: []
|
22
22
|
metadata: {}
|
23
23
|
post_install_message:
|
@@ -36,9 +36,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
36
|
version: '0'
|
37
37
|
requirements: []
|
38
38
|
rubyforge_project:
|
39
|
-
rubygems_version: 2.0.
|
39
|
+
rubygems_version: 2.0.5
|
40
40
|
signing_key:
|
41
41
|
specification_version: 4
|
42
|
-
summary:
|
42
|
+
summary: Range bound incrementing and decrementing by a specified amount
|
43
43
|
test_files: []
|
44
44
|
has_rdoc:
|