increments 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/increments.rb +14 -16
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13953c6652bbe6087c04964b96b0dfe81f47ae20
4
- data.tar.gz: b7977e5f912eb30aaa52a2fc79ab56b02d753f71
3
+ metadata.gz: 4437c3349327b61ddf3322fa91021884c41a74ec
4
+ data.tar.gz: 32cc783207051d6e182bb19e87cb5363f19af790
5
5
  SHA512:
6
- metadata.gz: cb4e981c18190097b98a32d56ce3e0c2f862b1f71ac13bb4a95837f418d858a40ed993c572ce0b547c1b15d3291c94b7e2a5fbcd71f2f2ea5ba159a4b668a230
7
- data.tar.gz: f9678777cb8da460669edb227647179ffece37cd113b25e2ea44fe1701c2f764e5dcb282f99ba9731a307ef60c5bb654fbff6ae8ead3edc33a24b244950d918c
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
- until max > options[:max]
6
+ loop do
7
7
  yield(min,max)
8
8
  break if max == options[:max]
9
- min = [min + options[:increment], options[:max]].min # Never exceed specified maximum
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
- until min < options[:min]
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
- def self.defaults
27
- {
28
- :min => 0,
29
- :max => 4294967295,
30
- :increment => 100000
31
- }
32
- end
26
+ private
33
27
 
34
- def self.number_of_batches(options=defaults)
35
- ((options[:max]-options[:min]+1.to_f)/options[:increment]).ceil
36
- end
28
+ def self.defaults
29
+ {
30
+ :min => 0,
31
+ :max => 4294967295,
32
+ :increment => 100000
33
+ }
34
+ end
37
35
 
38
- def self.validate(options)
39
- raise ArgumentError, "Invalid Options: #{options}" if options[:min] > options[:max] || options[:increment] <= 0
40
- end
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.2
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-06-13 00:00:00.000000000 Z
11
+ date: 2013-07-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A gem to facilitate incrementing values
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: http://rubygems.org/gems/increments
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.3
39
+ rubygems_version: 2.0.5
40
40
  signing_key:
41
41
  specification_version: 4
42
- summary: Increment values
42
+ summary: Range bound incrementing and decrementing by a specified amount
43
43
  test_files: []
44
44
  has_rdoc: