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 +4 -4
- data/lib/time_interval/repeating_interval.rb +15 -11
- data/lib/time_interval/version.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: 6c19e6c56117a74623c0b0be054d6b4cd555b090
|
4
|
+
data.tar.gz: 2aa769a3bb0baacbc67e0dd5195e10851d78110b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|