fat_period 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fat_period/period.rb +14 -6
- data/lib/fat_period/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: a1b3b656730fd4a24f6ec1ae3c14a2828aee91a6ddf18ce8a4481e31e2d55ad3
|
4
|
+
data.tar.gz: eb16ac79598e7c0054bac2ba57a9a5d8abce25cb8e810cbea9ac59ea4c8ead33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82b0fb1e076cf644da168edbfadfe44a060dc8ebdc43cdf450280a32466fc31a33aee79591a209d480cf192373cfcd8fe808f46e70e0c8186ff9fb10bdf84c66
|
7
|
+
data.tar.gz: d1a151a0b003ba1bcaa54562928ab42075044ae04bbabca202001c56b1fd697779666c870541f023dddf64e248dd1a1ee2e5eeea5484e2c6f0ee392af469e874
|
data/lib/fat_period/period.rb
CHANGED
@@ -77,6 +77,8 @@ class Period
|
|
77
77
|
# Wholly optional chunk part
|
78
78
|
(\s+per\s+(?<chunk_part>\w+))?\z}xi
|
79
79
|
|
80
|
+
private_constant :PHRASE_RE
|
81
|
+
|
80
82
|
# Return an array of periods, either a single period as in `Period.parse`
|
81
83
|
# from a String phrase in which a `from spec` is introduced with 'from' and,
|
82
84
|
# optionally, a `to spec` is introduced with 'to', or a number of periods if
|
@@ -99,8 +101,7 @@ class Period
|
|
99
101
|
#
|
100
102
|
# @param phrase [String] with 'from <spec> to <spec> [per <chunk>]'
|
101
103
|
# @return [Array<Period>] translated from phrase
|
102
|
-
def self.parse_phrase(phrase,
|
103
|
-
partial_first: false, partial_last: false, round_up_last: false)
|
104
|
+
def self.parse_phrase(phrase, partial_first: false, partial_last: false, round_up_last: false)
|
104
105
|
phrase = phrase.downcase.clean
|
105
106
|
mm = phrase.match(PHRASE_RE)
|
106
107
|
raise ArgumentError, "invalid period phrase: `#{phrase}`" unless mm
|
@@ -234,10 +235,15 @@ class Period
|
|
234
235
|
|
235
236
|
# Yield each day in this Period.
|
236
237
|
def each
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
238
|
+
if block_given?
|
239
|
+
d = first
|
240
|
+
while d <= last
|
241
|
+
yield d
|
242
|
+
d += 1.day
|
243
|
+
end
|
244
|
+
self
|
245
|
+
else
|
246
|
+
to_enum(:each)
|
241
247
|
end
|
242
248
|
end
|
243
249
|
|
@@ -318,6 +324,8 @@ class Period
|
|
318
324
|
half: (180..183), year: (365..366)
|
319
325
|
}.freeze
|
320
326
|
|
327
|
+
private_constant :CHUNK_ORDER, :CHUNK_RANGE
|
328
|
+
|
321
329
|
def self.chunk_cmp(chunk1, chunk2)
|
322
330
|
CHUNK_ORDER[chunk1] <=> CHUNK_ORDER[chunk2]
|
323
331
|
end
|
data/lib/fat_period/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fat_period
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel E. Doherty
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 4.8.3
|
111
|
-
description:
|
111
|
+
description:
|
112
112
|
email:
|
113
113
|
- ded-law@ddoherty.net
|
114
114
|
executables: []
|
@@ -132,7 +132,7 @@ files:
|
|
132
132
|
homepage: https://github.com/ddoherty03/fat_period
|
133
133
|
licenses: []
|
134
134
|
metadata: {}
|
135
|
-
post_install_message:
|
135
|
+
post_install_message:
|
136
136
|
rdoc_options: []
|
137
137
|
require_paths:
|
138
138
|
- lib
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubygems_version: 3.3.3
|
151
|
-
signing_key:
|
151
|
+
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: Implements a Period class as a Range of Dates.
|
154
154
|
test_files: []
|