time-interval 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc282ee85bc8d071ecadb4f82421d905378b1232
4
- data.tar.gz: 3772192417d37d39090ca4ecff853f8656a67596
3
+ metadata.gz: 6c19e6c56117a74623c0b0be054d6b4cd555b090
4
+ data.tar.gz: 2aa769a3bb0baacbc67e0dd5195e10851d78110b
5
5
  SHA512:
6
- metadata.gz: 67679c5a9f001e9935f823fd96b831e1e67e5491d00ac357eb0a846092f8058814020e12fbb3680bb1364be80cd9044298d85931146589324be4efee8135b2cc
7
- data.tar.gz: 1dc99d30fd7a1dd70faf76af7ece40524f46e59765d07eab40ff7390813ad60343044c6d34618a32ab0f6309419fa907742673af4f66f42949fcf3edcbdd05a1
6
+ metadata.gz: f00bda6968150c34b15b8c14574bd2645fc641cd2aba9404b8f34706890cb3f14927912092cac3ecc96295c9d11b37840eb25ea31a58a1e94f060157223e38ea
7
+ data.tar.gz: 640c3eeff7454ef811de018237aebd233fc503c7b22ca6855a4ce7ab4452608ef7ba18f983cf3b8ed83992c77802ce00960f536bc15507e5b852c79727fd8580
@@ -21,20 +21,10 @@ module TimeInterval
21
21
  def initialize(time_with_duration, times)
22
22
  @time_with_duration = time_with_duration
23
23
  @length = times
24
-
25
- @enumerator = Enumerator::Lazy.new(0...times) do |yielder, i|
26
- if i == 0
27
- yielder.yield time_with_duration
28
- else
29
- interval = time_with_duration
30
- i.times { interval = interval.step }
31
- yielder.yield interval
32
- end
33
- end
34
24
  end
35
25
 
36
26
  def each(&block)
37
- @enumerator.each(&block)
27
+ enumerator.each(&block)
38
28
  end
39
29
 
40
30
  def iso8601
@@ -44,5 +34,19 @@ module TimeInterval
44
34
  "R#{length}/#{@time_with_duration.iso8601}"
45
35
  end
46
36
  end
37
+
38
+ private
39
+
40
+ def enumerator
41
+ @enumerator ||= Enumerator::Lazy.new(0...length) do |yielder, i|
42
+ if i == 0
43
+ yielder.yield @time_with_duration
44
+ else
45
+ interval = @time_with_duration
46
+ i.times { interval = interval.step }
47
+ yielder.yield interval
48
+ end
49
+ end
50
+ end
47
51
  end
48
52
  end
@@ -1,3 +1,3 @@
1
1
  module TimeInterval
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time-interval
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Edwards
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler