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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7941bd64bd2ffee84449e892558f43592866010fcd92d8809be7df94ec80f3a
4
- data.tar.gz: f9ae67f04f0e5134700c4ad535d69f94f7e685607bb3fa8d9e69946c6610104b
3
+ metadata.gz: 9a25b58d14031a244e50f9fa43183185569b998de5ab57e6736f790603b0dd45
4
+ data.tar.gz: ff3addde0b9d4ece8155b06ef7e708717152a07297f029006d435f4093419197
5
5
  SHA512:
6
- metadata.gz: 0a2c4d506c93db39dd5e56ab5a562294d747e47977133191fe9682879dd1cfafb146214812a698da2837443e0a0aa32805e25c1991ebb0881b825eb596fc5929
7
- data.tar.gz: eb6686a639cd867b90a938425abdb90f2465b2dc1fdefe79fb3d20a9ca1e66f477056a3a0b85d469e1e12794d94eec4771e63fcd781cb6e312d6169fd8cb8648
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
- mon = Date.new(2021, 8, 2) # = 1st Monday
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(mon) << Enumdate.weekly(wed))
121
+ (Enumdate::EnumMerger.new << Enumdate.weekly(first) << Enumdate.weekly(first, wday: 1))
123
122
  .lazy.map(&:to_s).take(4).force
124
- # => ["2021-08-02", "2021-08-04", "2021-08-09", "2021-08-11"]
123
+ # => ["2021-08-04", "2021-08-09", "2021-08-11", "2021-08-16"]
125
124
  #+end_src
126
125
 
127
126
  ** Installation
@@ -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
- yield next_minimum(@enumerators)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enumdate
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.0
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-22 00:00:00.000000000 Z
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: []