fat_period 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb2c6b600f446fa2bff8080b8056a32ceb3fda88be68c03db076591753c4992e
4
- data.tar.gz: f4d65daa079f338c2a1a7ab5a0d326ae9af884d819a72077f1f24e8128ed70de
3
+ metadata.gz: a1b3b656730fd4a24f6ec1ae3c14a2828aee91a6ddf18ce8a4481e31e2d55ad3
4
+ data.tar.gz: eb16ac79598e7c0054bac2ba57a9a5d8abce25cb8e810cbea9ac59ea4c8ead33
5
5
  SHA512:
6
- metadata.gz: 3059659aed2c2000401a6fceca177b9b7ea633adaaa1012bcb20db1069845bdc7dff35b97a53289a498399d1bc2217ceffd06c4dae94377ce7a47710c71ab2af
7
- data.tar.gz: ab0e1a8aebca6fc8acf0e952e9a48956767b03e7cd9071d6487b52e0a544519e6801b927ae3b2f5021e1fc3ac8aeb95114488192fcd343b265b235efc38a6784
6
+ metadata.gz: 82b0fb1e076cf644da168edbfadfe44a060dc8ebdc43cdf450280a32466fc31a33aee79591a209d480cf192373cfcd8fe808f46e70e0c8186ff9fb10bdf84c66
7
+ data.tar.gz: d1a151a0b003ba1bcaa54562928ab42075044ae04bbabca202001c56b1fd697779666c870541f023dddf64e248dd1a1ee2e5eeea5484e2c6f0ee392af469e874
@@ -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
- d = first
238
- while d <= last
239
- yield d
240
- d += 1.day
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
@@ -1,3 +1,3 @@
1
1
  module FatPeriod
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.3.1'.freeze
3
3
  end
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.0
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-08 00:00:00.000000000 Z
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: []