fat_core 5.6.1 → 6.0.0
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 +4 -4
- data/.rubocop.yml +0 -4
- data/README.org +38 -409
- data/bin/console +1 -3
- data/lib/fat_core/all.rb +0 -1
- data/lib/fat_core/string.rb +0 -20
- data/lib/fat_core/version.rb +3 -3
- data/lib/fat_core.rb +0 -2
- data/spec/lib/range_spec.rb +91 -90
- data/spec/lib/string_spec.rb +0 -9
- metadata +4 -8
- data/bin/easter +0 -45
- data/lib/fat_core/date.rb +0 -1897
- data/spec/lib/date_spec.rb +0 -1390
data/spec/lib/range_spec.rb
CHANGED
|
@@ -4,100 +4,101 @@ require 'fat_core/range'
|
|
|
4
4
|
describe Range do
|
|
5
5
|
describe 'set operations' do
|
|
6
6
|
it 'knows if it is a subset of another range' do
|
|
7
|
-
expect((4..8)
|
|
8
|
-
expect((4..8)
|
|
9
|
-
expect((4..8)
|
|
10
|
-
expect((4..8)
|
|
11
|
-
expect((4..8)
|
|
7
|
+
expect((4..8).subset_of?(2..9)).to be true
|
|
8
|
+
expect((4..8).subset_of?(4..8)).to be true
|
|
9
|
+
expect((4..8).subset_of?(2..7)).to be false
|
|
10
|
+
expect((4..8).subset_of?(5..8)).to be false
|
|
11
|
+
expect((4..8).subset_of?(11..20)).to be false
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it 'knows if it is a proper subset of another range' do
|
|
15
|
-
expect((4..8)
|
|
16
|
-
expect((4..8)
|
|
17
|
-
expect((4..8)
|
|
18
|
-
expect((4..8)
|
|
19
|
-
expect((4..8)
|
|
20
|
-
expect((4..8)
|
|
15
|
+
expect((4..8).proper_subset_of?(2..9)).to be true
|
|
16
|
+
expect((4..8).proper_subset_of?(4..9)).to be true
|
|
17
|
+
expect((4..8).proper_subset_of?(4..8)).to be false
|
|
18
|
+
expect((4..8).proper_subset_of?(2..7)).to be false
|
|
19
|
+
expect((4..8).proper_subset_of?(5..8)).to be false
|
|
20
|
+
expect((4..8).proper_subset_of?(11..20)).to be false
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'knows if it is a superset of another range' do
|
|
24
|
-
expect((4..8)
|
|
25
|
-
expect((4..8)
|
|
26
|
-
expect((4..8)
|
|
27
|
-
expect((4..8)
|
|
28
|
-
expect((4..8)
|
|
29
|
-
expect((4..8)
|
|
30
|
-
expect((4..8)
|
|
31
|
-
expect((4..8)
|
|
32
|
-
expect((4..8)
|
|
33
|
-
expect((4..8)
|
|
34
|
-
expect((4..8)
|
|
24
|
+
expect((4..8).superset_of?(5..7)).to be true
|
|
25
|
+
expect((4..8).superset_of?(6..8)).to be true
|
|
26
|
+
expect((4..8).superset_of?(4..7)).to be true
|
|
27
|
+
expect((4..8).superset_of?(4..8)).to be true
|
|
28
|
+
expect((4..8).superset_of?(2..9)).to be false
|
|
29
|
+
expect((4..8).superset_of?(2..8)).to be false
|
|
30
|
+
expect((4..8).superset_of?(4..9)).to be false
|
|
31
|
+
expect((4..8).superset_of?(8..20)).to be false
|
|
32
|
+
expect((4..8).superset_of?(0..4)).to be false
|
|
33
|
+
expect((4..8).superset_of?(0..3)).to be false
|
|
34
|
+
expect((4..8).superset_of?(9..20)).to be false
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it 'knows if it is a proper superset of another range' do
|
|
38
|
-
expect((4..8)
|
|
39
|
-
expect((4..8)
|
|
40
|
-
expect((4..8)
|
|
41
|
-
expect((4..8)
|
|
42
|
-
expect((4..8)
|
|
43
|
-
expect((4..8)
|
|
44
|
-
expect((4..8)
|
|
45
|
-
expect((4..8)
|
|
46
|
-
expect((4..8)
|
|
47
|
-
expect((4..8)
|
|
48
|
-
expect((4..8)
|
|
38
|
+
expect((4..8).proper_superset_of?(5..7)).to be true
|
|
39
|
+
expect((4..8).proper_superset_of?(6..8)).to be true
|
|
40
|
+
expect((4..8).proper_superset_of?(4..7)).to be true
|
|
41
|
+
expect((4..8).proper_superset_of?(4..8)).to be false
|
|
42
|
+
expect((4..8).proper_superset_of?(2..9)).to be false
|
|
43
|
+
expect((4..8).proper_superset_of?(2..8)).to be false
|
|
44
|
+
expect((4..8).proper_superset_of?(4..9)).to be false
|
|
45
|
+
expect((4..8).proper_superset_of?(8..20)).to be false
|
|
46
|
+
expect((4..8).proper_superset_of?(0..4)).to be false
|
|
47
|
+
expect((4..8).proper_superset_of?(0..3)).to be false
|
|
48
|
+
expect((4..8).proper_superset_of?(9..20)).to be false
|
|
49
|
+
expect((4..8).proper_superset_of?(4..8)).to be false
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
it 'knows its intersection with another range' do
|
|
52
|
-
expect((
|
|
53
|
-
expect((
|
|
54
|
-
expect((
|
|
53
|
+
expect((0..10) & (5..20)).to eq(5..10)
|
|
54
|
+
expect((0..10) & (5..20)).to eq((5..20) & (0..10))
|
|
55
|
+
expect((0..10) & (10..20)).to eq(10..10)
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
it 'intersection should return nil if there is no overlap' do
|
|
58
|
-
expect((
|
|
59
|
+
expect((0..10) & (15..20)).to be_nil
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
it 'knows its union with another range' do
|
|
62
|
-
expect((
|
|
63
|
-
expect((
|
|
64
|
-
expect((
|
|
63
|
+
expect((0..10) + (5..20)).to eq(0..20)
|
|
64
|
+
expect((0..10) + (5..20)).to eq((5..20) + (0..10))
|
|
65
|
+
expect((0..10) + (10..20)).to eq(0..20)
|
|
65
66
|
|
|
66
67
|
# For discrete values, union should work on contiguous ranges
|
|
67
|
-
expect((
|
|
68
|
+
expect((0..5) + (6..20)).to eq(0..20)
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
it 'union should return nil if there is no overlap' do
|
|
71
|
-
expect((
|
|
72
|
-
expect((
|
|
72
|
+
expect((0..10) & (15..20)).to be_nil
|
|
73
|
+
expect((15..20) & (0..10)).to be_nil
|
|
73
74
|
end
|
|
74
75
|
|
|
75
76
|
it 'knows the difference with another range' do
|
|
76
77
|
# Other is same as self
|
|
77
78
|
# xrubocop:disable Lint/BinaryOperatorWithIdenticalOperands
|
|
78
79
|
expect(((4..10) - (4..10)).size).to eq(0)
|
|
79
|
-
expect((
|
|
80
|
+
expect((4..10) - (4..10)).to be_empty
|
|
80
81
|
# xrubocop:enable Lint/BinaryOperatorWithIdenticalOperands
|
|
81
82
|
|
|
82
83
|
# Other is proper subset of self
|
|
83
|
-
expect(((4..10) - (6..7)).first).to eq(
|
|
84
|
-
expect(((4..10) - (6..7)).last).to eq(
|
|
85
|
-
expect(((4..10) - (6..10)).first).to eq(
|
|
86
|
-
expect(((4..10) - (4..7)).last).to eq(
|
|
84
|
+
expect(((4..10) - (6..7)).first).to eq(4..5)
|
|
85
|
+
expect(((4..10) - (6..7)).last).to eq(8..10)
|
|
86
|
+
expect(((4..10) - (6..10)).first).to eq(4..5)
|
|
87
|
+
expect(((4..10) - (4..7)).last).to eq(8..10)
|
|
87
88
|
|
|
88
89
|
# Other overlaps on the left
|
|
89
90
|
expect(((4..10) - (0..6)).size).to eq(1)
|
|
90
|
-
expect(((4..10) - (0..6)).first).to eq(
|
|
91
|
+
expect(((4..10) - (0..6)).first).to eq(7..10)
|
|
91
92
|
|
|
92
93
|
expect(((4..10) - (4..6)).size).to eq(1)
|
|
93
|
-
expect(((4..10) - (4..6)).first).to eq(
|
|
94
|
+
expect(((4..10) - (4..6)).first).to eq(7..10)
|
|
94
95
|
|
|
95
96
|
# Other overlaps on the right
|
|
96
97
|
expect(((4..10) - (7..11)).size).to eq(1)
|
|
97
|
-
expect(((4..10) - (7..11)).first).to eq(
|
|
98
|
+
expect(((4..10) - (7..11)).first).to eq(4..6)
|
|
98
99
|
|
|
99
100
|
expect(((4..10) - (7..10)).size).to eq(1)
|
|
100
|
-
expect(((4..10) - (7..10)).last).to eq(
|
|
101
|
+
expect(((4..10) - (7..10)).last).to eq(4..6)
|
|
101
102
|
|
|
102
103
|
# Other does not overlap
|
|
103
104
|
expect((4..10) - (13..20)).to eq([(4..10)])
|
|
@@ -107,8 +108,8 @@ describe Range do
|
|
|
107
108
|
|
|
108
109
|
describe 'joining' do
|
|
109
110
|
it 'can join contiguous ranges' do
|
|
110
|
-
expect((0..3).join(4..8)).to eq(
|
|
111
|
-
expect((4..8).join(0..3)).to eq(
|
|
111
|
+
expect((0..3).join(4..8)).to eq(0..8)
|
|
112
|
+
expect((4..8).join(0..3)).to eq(0..8)
|
|
112
113
|
end
|
|
113
114
|
|
|
114
115
|
it 'returns nil on join of non-contiguous ranges' do
|
|
@@ -120,51 +121,51 @@ describe Range do
|
|
|
120
121
|
end
|
|
121
122
|
|
|
122
123
|
it 'works with Floats, allowing single-point overlap' do
|
|
123
|
-
expect((0.0..3.0).join(3.0..8.2)).to eq(
|
|
124
|
-
expect((3.0..8.2).join(0.0..3.0)).to eq(
|
|
124
|
+
expect((0.0..3.0).join(3.0..8.2)).to eq(0.0..8.2)
|
|
125
|
+
expect((3.0..8.2).join(0.0..3.0)).to eq(0.0..8.2)
|
|
125
126
|
end
|
|
126
127
|
end
|
|
127
128
|
|
|
128
129
|
describe 'spanning' do
|
|
129
130
|
it 'can determine whether it is spanned by a set of ranges' do
|
|
130
|
-
expect((0..10)
|
|
131
|
+
expect((0..10).spanned_by?([(0..3), (4..6), (7..10)])).to be true
|
|
131
132
|
end
|
|
132
133
|
|
|
133
134
|
it 'can determine that overlapping ranges do not span' do
|
|
134
|
-
expect((0..10)
|
|
135
|
+
expect((0..10).spanned_by?([(0..3), (3..6), (7..10)])).to be false
|
|
135
136
|
end
|
|
136
137
|
|
|
137
138
|
it 'allows spanning ranges to be any Enumerable' do
|
|
138
139
|
require 'set'
|
|
139
140
|
set = [(0..3), (4..6), (7..10)].to_set
|
|
140
|
-
expect((0..10)).to
|
|
141
|
+
expect((0..10).spanned_by?(set)).to be true
|
|
141
142
|
set = [(0...3), (4..6), (7..10)].to_set
|
|
142
|
-
expect((0..10)
|
|
143
|
+
expect((0..10).spanned_by?(set)).to be false
|
|
143
144
|
end
|
|
144
145
|
|
|
145
146
|
it 'allows the spanning set to be wider than itself' do
|
|
146
147
|
set = [(0..3), (4..6), (7..10)].to_set
|
|
147
|
-
expect((2..8)).to
|
|
148
|
-
expect((5..6)).to
|
|
148
|
+
expect((2..8).spanned_by?(set)).to be true
|
|
149
|
+
expect((5..6).spanned_by?(set)).to be true
|
|
149
150
|
end
|
|
150
151
|
end
|
|
151
152
|
|
|
152
153
|
describe 'overlapping a single range' do
|
|
153
154
|
it 'knows if another range overlaps it' do
|
|
154
|
-
expect((0..10)
|
|
155
|
-
expect((0..10)
|
|
156
|
-
expect((0..10)
|
|
157
|
-
expect((0..10)
|
|
158
|
-
expect((0..10)
|
|
159
|
-
expect((0..10)
|
|
155
|
+
expect((0..10).overlaps?(-3..5)).to be true
|
|
156
|
+
expect((0..10).overlaps?(3..5)).to be true
|
|
157
|
+
expect((0..10).overlaps?(8..15)).to be true
|
|
158
|
+
expect((0..10).overlaps?(0..10)).to be true
|
|
159
|
+
expect((0..10).overlaps?(11..12)).to be false
|
|
160
|
+
expect((0..10).overlaps?(-11..-1)).to be false
|
|
160
161
|
|
|
161
162
|
# Order of operands should not matter
|
|
162
|
-
expect((-3..5)
|
|
163
|
-
expect((3..5)
|
|
164
|
-
expect((8..15)
|
|
165
|
-
expect((0..10)
|
|
166
|
-
expect((11..12)
|
|
167
|
-
expect((-11..-1)
|
|
163
|
+
expect((-3..5).overlaps?(0..10)).to be true
|
|
164
|
+
expect((3..5).overlaps?(0..10)).to be true
|
|
165
|
+
expect((8..15).overlaps?(0..10)).to be true
|
|
166
|
+
expect((0..10).overlaps?(0..10)).to be true
|
|
167
|
+
expect((11..12).overlaps?(0..10)).to be false
|
|
168
|
+
expect((-11..-1).overlaps?(0..10)).to be false
|
|
168
169
|
end
|
|
169
170
|
|
|
170
171
|
it 'can determine whether a set contains covered overlaps' do
|
|
@@ -201,8 +202,8 @@ describe Range do
|
|
|
201
202
|
|
|
202
203
|
it 'returns an array of gaps' do
|
|
203
204
|
gaps = (0..10).gaps([(0..3), (5..6), (9..10)])
|
|
204
|
-
expect(gaps[0]).to eq(
|
|
205
|
-
expect(gaps[1]).to eq(
|
|
205
|
+
expect(gaps[0]).to eq(4..4)
|
|
206
|
+
expect(gaps[1]).to eq(7..8)
|
|
206
207
|
end
|
|
207
208
|
|
|
208
209
|
it 'allows ranges to extend before and after self' do
|
|
@@ -213,30 +214,30 @@ describe Range do
|
|
|
213
214
|
it 'does not include parts before or after in gaps' do
|
|
214
215
|
gaps = (0..10).gaps([(-10..-8), (-3..3), (7..13), (30..40)])
|
|
215
216
|
expect(gaps.size).to eq(1)
|
|
216
|
-
expect(gaps[0]).to eq(
|
|
217
|
+
expect(gaps[0]).to eq(4..6)
|
|
217
218
|
end
|
|
218
219
|
|
|
219
220
|
it 'includes gaps at beginning and end' do
|
|
220
221
|
gaps = (0..10).gaps([(2..3), (4..6), (7..8)])
|
|
221
|
-
expect(gaps[0]).to eq(
|
|
222
|
-
expect(gaps[1]).to eq(
|
|
222
|
+
expect(gaps[0]).to eq(0..1)
|
|
223
|
+
expect(gaps[1]).to eq(9..10)
|
|
223
224
|
end
|
|
224
225
|
|
|
225
226
|
it 'works even if ranges are out of order' do
|
|
226
227
|
gaps = (0..10).gaps([(2..3), (30..40), (7..8), (-10..-8), (4..6)])
|
|
227
|
-
expect(gaps[0]).to eq(
|
|
228
|
-
expect(gaps[1]).to eq(
|
|
228
|
+
expect(gaps[0]).to eq(0..1)
|
|
229
|
+
expect(gaps[1]).to eq(9..10)
|
|
229
230
|
end
|
|
230
231
|
|
|
231
232
|
it 'notices single point coverage' do
|
|
232
233
|
gaps = (0..10).gaps([(4..4), (5..5), (6..6)])
|
|
233
|
-
expect(gaps[0]).to eq(
|
|
234
|
-
expect(gaps[1]).to eq(
|
|
234
|
+
expect(gaps[0]).to eq(0..3)
|
|
235
|
+
expect(gaps[1]).to eq(7..10)
|
|
235
236
|
end
|
|
236
237
|
|
|
237
238
|
it 'works for a single-point range' do
|
|
238
239
|
gaps = (3..3).gaps([(0..2), (4..4), (5..5), (6..6)])
|
|
239
|
-
expect(gaps[0]).to eq(
|
|
240
|
+
expect(gaps[0]).to eq(3..3)
|
|
240
241
|
end
|
|
241
242
|
|
|
242
243
|
it 'works even if ranges overlap' do
|
|
@@ -265,22 +266,22 @@ describe Range do
|
|
|
265
266
|
it 'returns an array of overlaps' do
|
|
266
267
|
overlaps = (0..10).overlaps([(0..3), (2..6), (4..10)])
|
|
267
268
|
expect(overlaps.size).to eq(2)
|
|
268
|
-
expect(overlaps[0]).to eq(
|
|
269
|
-
expect(overlaps[1]).to eq(
|
|
269
|
+
expect(overlaps[0]).to eq(2..3)
|
|
270
|
+
expect(overlaps[1]).to eq(4..6)
|
|
270
271
|
end
|
|
271
272
|
|
|
272
273
|
it 'does not return any overlaps before self' do
|
|
273
274
|
overlaps = (0..10).overlaps([(-5..-3), (-4..-1), (0..3), (2..6), (4..10)])
|
|
274
275
|
expect(overlaps.size).to eq(2)
|
|
275
|
-
expect(overlaps[0]).to eq(
|
|
276
|
-
expect(overlaps[1]).to eq(
|
|
276
|
+
expect(overlaps[0]).to eq(2..3)
|
|
277
|
+
expect(overlaps[1]).to eq(4..6)
|
|
277
278
|
end
|
|
278
279
|
|
|
279
280
|
it 'does not return any overlaps after self' do
|
|
280
281
|
overlaps = (0..10).overlaps([(0..3), (2..6), (4..15), (11..20)])
|
|
281
282
|
expect(overlaps.size).to eq(2)
|
|
282
|
-
expect(overlaps[0]).to eq(
|
|
283
|
-
expect(overlaps[1]).to eq(
|
|
283
|
+
expect(overlaps[0]).to eq(2..3)
|
|
284
|
+
expect(overlaps[1]).to eq(4..6)
|
|
284
285
|
end
|
|
285
286
|
end
|
|
286
287
|
end
|
data/spec/lib/string_spec.rb
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
require 'fat_core/string'
|
|
5
|
-
require 'fat_core/date'
|
|
6
5
|
|
|
7
6
|
describe String do
|
|
8
7
|
describe 'class methods' do
|
|
@@ -144,14 +143,6 @@ the people, for the people, shall not perish from the earth."
|
|
|
144
143
|
end
|
|
145
144
|
end
|
|
146
145
|
|
|
147
|
-
it 'converts a digital date to a Date' do
|
|
148
|
-
expect('20140521'.as_date.iso).to eq '2014-05-21'
|
|
149
|
-
expect('2014-05-21'.as_date.iso).to eq '2014-05-21'
|
|
150
|
-
expect('2014/05/21'.as_date.iso).to eq '2014-05-21'
|
|
151
|
-
expect('2014/5/21'.as_date.iso).to eq '2014-05-21'
|
|
152
|
-
expect('201X/5/21'.as_date).to be_nil
|
|
153
|
-
end
|
|
154
|
-
|
|
155
146
|
it 'converts a string to a regular expression' do
|
|
156
147
|
# Ignores case by default
|
|
157
148
|
re = "/hello((\s+)(world))?/".as_regexp
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fat_core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel E. Doherty
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -73,8 +73,7 @@ description: |
|
|
|
73
73
|
iteration, (also for Hash), set operations on Ranges
|
|
74
74
|
email:
|
|
75
75
|
- ded@ddoherty.net
|
|
76
|
-
executables:
|
|
77
|
-
- easter
|
|
76
|
+
executables: []
|
|
78
77
|
extensions: []
|
|
79
78
|
extra_rdoc_files: []
|
|
80
79
|
files:
|
|
@@ -91,14 +90,12 @@ files:
|
|
|
91
90
|
- Rakefile
|
|
92
91
|
- TODO.org
|
|
93
92
|
- bin/console
|
|
94
|
-
- bin/easter
|
|
95
93
|
- fat_core.gemspec
|
|
96
94
|
- lib/fat_core.rb
|
|
97
95
|
- lib/fat_core/ChangeLog
|
|
98
96
|
- lib/fat_core/all.rb
|
|
99
97
|
- lib/fat_core/array.rb
|
|
100
98
|
- lib/fat_core/bigdecimal.rb
|
|
101
|
-
- lib/fat_core/date.rb
|
|
102
99
|
- lib/fat_core/enumerable.rb
|
|
103
100
|
- lib/fat_core/hash.rb
|
|
104
101
|
- lib/fat_core/kernel.rb
|
|
@@ -111,7 +108,6 @@ files:
|
|
|
111
108
|
- lib/fat_core/version.rb
|
|
112
109
|
- spec/lib/array_spec.rb
|
|
113
110
|
- spec/lib/big_decimal_spec.rb
|
|
114
|
-
- spec/lib/date_spec.rb
|
|
115
111
|
- spec/lib/enumerable_spec.rb
|
|
116
112
|
- spec/lib/hash_spec.rb
|
|
117
113
|
- spec/lib/kernel_spec.rb
|
|
@@ -140,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
140
136
|
- !ruby/object:Gem::Version
|
|
141
137
|
version: '0'
|
|
142
138
|
requirements: []
|
|
143
|
-
rubygems_version: 3.6.
|
|
139
|
+
rubygems_version: 3.6.7
|
|
144
140
|
specification_version: 4
|
|
145
141
|
summary: some useful core extensions
|
|
146
142
|
test_files: []
|
data/bin/easter
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "debug"
|
|
5
|
-
require 'fat_core/date'
|
|
6
|
-
|
|
7
|
-
usage = <<~HELP
|
|
8
|
-
USAGE:
|
|
9
|
-
easter -- print the date of Easter for the current year
|
|
10
|
-
easter year -- print the date of Easter for the given year
|
|
11
|
-
easter year1 year2 -- print the dates of Easter from year1 to year2
|
|
12
|
-
|
|
13
|
-
Note: if the date of Easter is the earliest possible, it is marked with a '<';
|
|
14
|
-
if it is the latest date possible, it is marked with a '>'
|
|
15
|
-
HELP
|
|
16
|
-
first, last = *ARGV
|
|
17
|
-
first ||= Date.today.year
|
|
18
|
-
last ||= Date.today.year
|
|
19
|
-
|
|
20
|
-
if first.to_s.match?(/--help|-h/)
|
|
21
|
-
puts usage
|
|
22
|
-
exit(1)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
begin
|
|
26
|
-
first = Integer(first)
|
|
27
|
-
last = Integer(last)
|
|
28
|
-
rescue ArgumentError
|
|
29
|
-
warn "!!Error: invalid year number given\n\n"
|
|
30
|
-
puts usage
|
|
31
|
-
exit(2)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
(first..last).each do |yr|
|
|
35
|
-
easter = Date.easter(yr)
|
|
36
|
-
sig =
|
|
37
|
-
if easter.month == 4 && easter.day >= 25
|
|
38
|
-
' >'
|
|
39
|
-
elsif easter.month == 3 && easter.day <= 22
|
|
40
|
-
' <'
|
|
41
|
-
else
|
|
42
|
-
''
|
|
43
|
-
end
|
|
44
|
-
puts "Easter #{yr}: #{easter.iso}#{sig}"
|
|
45
|
-
end
|