enumdate 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.org +3 -4
- data/lib/enumdate/enum_merger.rb +6 -1
- data/lib/enumdate/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a25b58d14031a244e50f9fa43183185569b998de5ab57e6736f790603b0dd45
|
4
|
+
data.tar.gz: ff3addde0b9d4ece8155b06ef7e708717152a07297f029006d435f4093419197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1700c8d0d9dd2f8ce923398de531ee68a043ea6a9d9d9a8d49bd64891d829241fb4a5695645540c5afeb314a136968d47f3ac8ddc8e3fbcd98898993cd2f60c6
|
7
|
+
data.tar.gz: e9a4e9d2fafe8b2be5c054d305fd8a8352e1b9666ecfc0c5b9d93358a2379b96ea7b525ff4cafcfa38324b2dd3382d6b352e9dfbb91433acb9addbd0b4388181
|
data/README.org
CHANGED
@@ -115,13 +115,12 @@
|
|
115
115
|
Sometimes, you may need to compose more complex recurring patterns.
|
116
116
|
In this case, you can merge multiple enumerables:
|
117
117
|
#+begin_src ruby
|
118
|
-
|
119
|
-
wed = Date.new(2021, 8, 4) # = 1st Wednesday
|
118
|
+
first = Date.new(2021, 8, 4) # Wednesday
|
120
119
|
|
121
120
|
# Every Monday and Wednesday:
|
122
|
-
(Enumdate::EnumMerger.new << Enumdate.weekly(
|
121
|
+
(Enumdate::EnumMerger.new << Enumdate.weekly(first) << Enumdate.weekly(first, wday: 1))
|
123
122
|
.lazy.map(&:to_s).take(4).force
|
124
|
-
# => ["2021-08-
|
123
|
+
# => ["2021-08-04", "2021-08-09", "2021-08-11", "2021-08-16"]
|
125
124
|
#+end_src
|
126
125
|
|
127
126
|
** Installation
|
data/lib/enumdate/enum_merger.rb
CHANGED
@@ -17,8 +17,13 @@ module Enumdate
|
|
17
17
|
def each
|
18
18
|
return enum_for(:each) unless block_given?
|
19
19
|
|
20
|
+
previous, has_valid_previous = nil, false
|
20
21
|
loop do
|
21
|
-
|
22
|
+
current = next_minimum(@enumerators)
|
23
|
+
next if has_valid_previous && current == previous
|
24
|
+
|
25
|
+
yield current
|
26
|
+
previous, has_valid_previous = current, true
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
data/lib/enumdate/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumdate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshinari Nomura
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description:
|
14
14
|
email:
|
15
15
|
- nom@quickhack.net
|
16
16
|
executables: []
|
@@ -40,7 +40,7 @@ licenses:
|
|
40
40
|
metadata:
|
41
41
|
homepage_uri: https://github.com/yoshinari-nomura/enumdate
|
42
42
|
source_code_uri: https://github.com/yoshinari-nomura/enumdate
|
43
|
-
post_install_message:
|
43
|
+
post_install_message:
|
44
44
|
rdoc_options: []
|
45
45
|
require_paths:
|
46
46
|
- lib
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubygems_version: 3.2.22
|
59
|
-
signing_key:
|
59
|
+
signing_key:
|
60
60
|
specification_version: 4
|
61
61
|
summary: Enumerator for recurring dates.
|
62
62
|
test_files: []
|