zakuro 0.0.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +102 -42
- data/doc/operation.md +25 -0
- data/doc/operation/csv/month.csv +202 -0
- data/doc/operation/operation.xlsx +0 -0
- data/doc/operation/transfer.rb +77 -0
- data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
- data/lib/zakuro/calculation/base/year.rb +107 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +459 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
- data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
- data/lib/zakuro/calculation/monthly/month.rb +187 -0
- data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
- data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
- data/lib/zakuro/calculation/range/full_range.rb +210 -0
- data/lib/zakuro/calculation/range/operated_range.rb +144 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
- data/lib/zakuro/calculation/summary/single.rb +129 -0
- data/lib/zakuro/condition.rb +16 -13
- data/lib/zakuro/era/japan/gengou.rb +106 -0
- data/lib/zakuro/era/japan/gengou/parser.rb +167 -0
- data/lib/zakuro/era/japan/gengou/type.rb +178 -0
- data/lib/zakuro/era/japan/gengou/validator.rb +236 -0
- data/lib/zakuro/era/japan/reki.rb +91 -0
- data/lib/zakuro/era/{gengou → japan/yaml}/set-001-until-south.yaml +0 -0
- data/lib/zakuro/era/{gengou → japan/yaml}/set-002-from-north.yaml +0 -0
- data/lib/zakuro/era/{gengou → japan/yaml}/set-003-modern.yaml +0 -0
- data/lib/zakuro/era/western.rb +1 -1
- data/lib/zakuro/merchant.rb +2 -2
- data/lib/zakuro/operation/month/parser.rb +373 -0
- data/lib/zakuro/operation/month/type.rb +453 -0
- data/lib/zakuro/operation/month/validator.rb +802 -0
- data/lib/zakuro/operation/operation.rb +66 -0
- data/lib/zakuro/operation/yaml/month.yaml +6452 -0
- data/lib/zakuro/output/error.rb +7 -4
- data/lib/zakuro/output/logger.rb +50 -47
- data/lib/zakuro/output/response.rb +146 -143
- data/lib/zakuro/result/core.rb +52 -0
- data/lib/zakuro/result/data.rb +187 -0
- data/lib/zakuro/result/operation.rb +114 -0
- data/lib/zakuro/result/result.rb +37 -0
- data/lib/zakuro/{output → tools}/stringifier.rb +16 -9
- data/lib/zakuro/tools/typeof.rb +33 -0
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/abstract_version.rb +1 -1
- data/lib/zakuro/version/context.rb +23 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +63 -0
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +31 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +186 -182
- data/lib/zakuro/version/senmyou/range/annual_range.rb +167 -0
- data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +6 -6
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +103 -152
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +213 -0
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +3 -184
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +4 -4
- data/lib/zakuro/version/version_class_resolver.rb +62 -0
- data/lib/zakuro/version_factory.rb +3 -3
- metadata +53 -24
- data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
- data/lib/zakuro/cycle/zodiac.rb +0 -103
- data/lib/zakuro/era/japan.rb +0 -664
- data/lib/zakuro/output/result.rb +0 -225
- data/lib/zakuro/version/senmyou/base/era.rb +0 -83
- data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
- data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -205
- data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
- data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -66
- data/lib/zakuro/version/senmyou/base/year.rb +0 -104
- data/lib/zakuro/version/senmyou/monthly/month.rb +0 -122
- data/lib/zakuro/version/senmyou/summary/annual_range.rb +0 -187
- data/lib/zakuro/version/senmyou/summary/full_range.rb +0 -224
- data/lib/zakuro/version/senmyou/summary/specifier.rb +0 -100
@@ -0,0 +1,453 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require_relative '../../era/western'
|
5
|
+
require_relative './validator'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
#
|
10
|
+
# Operation 運用
|
11
|
+
#
|
12
|
+
module Operation
|
13
|
+
#
|
14
|
+
# 日(差分)無効値
|
15
|
+
#
|
16
|
+
INVALID_DAY_VALUE = -30
|
17
|
+
|
18
|
+
# :reek:TooManyInstanceVariables { max_instance_variables: 6 }
|
19
|
+
|
20
|
+
#
|
21
|
+
# MonthHistory 変更履歴
|
22
|
+
#
|
23
|
+
class MonthHistory
|
24
|
+
# @return [String] ID
|
25
|
+
attr_reader :id
|
26
|
+
# @return [String] 親ID
|
27
|
+
attr_reader :parent_id
|
28
|
+
# @return [Reference] 参照
|
29
|
+
attr_reader :reference
|
30
|
+
# @return [Western::Calendar] 西暦日
|
31
|
+
attr_reader :western_date
|
32
|
+
# @return [Array<Annotation>] 注釈
|
33
|
+
attr_reader :annotations
|
34
|
+
# @return [Diffs] 総差分
|
35
|
+
attr_reader :diffs
|
36
|
+
|
37
|
+
# rubocop:disable Metrics/ParameterLists
|
38
|
+
# :reek:LongParameterList { max_params: 6 }
|
39
|
+
|
40
|
+
#
|
41
|
+
# 初期化
|
42
|
+
#
|
43
|
+
# @param [String] id ID
|
44
|
+
# @param [String] parent_id 親ID
|
45
|
+
# @param [Reference] reference 参照
|
46
|
+
# @param [Western::Calendar] western_date 西暦日
|
47
|
+
# @param [Array<Annotation>] annotations 注釈
|
48
|
+
# @param [Diffs] diffs 総差分
|
49
|
+
#
|
50
|
+
def initialize(id: '', parent_id: '', reference: Reference.new,
|
51
|
+
western_date: Western::Calendar.new, annotations: [], diffs: Diffs.new)
|
52
|
+
@id = id
|
53
|
+
@parent_id = parent_id
|
54
|
+
@reference = reference
|
55
|
+
@western_date = western_date
|
56
|
+
@annotations = annotations
|
57
|
+
@diffs = diffs
|
58
|
+
end
|
59
|
+
# rubocop:enable Metrics/ParameterLists
|
60
|
+
|
61
|
+
#
|
62
|
+
# 無効か
|
63
|
+
#
|
64
|
+
# @return [True] 無効
|
65
|
+
# @return [False] 有効
|
66
|
+
#
|
67
|
+
def invalid?
|
68
|
+
id == ''
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# Annotation 注釈
|
74
|
+
#
|
75
|
+
class Annotation
|
76
|
+
# @return [String] ID
|
77
|
+
attr_reader :id
|
78
|
+
# @return [String] 内容
|
79
|
+
attr_reader :description
|
80
|
+
# @return [String] 正誤訂正(zakuro)
|
81
|
+
attr_reader :note
|
82
|
+
|
83
|
+
#
|
84
|
+
# 初期化
|
85
|
+
#
|
86
|
+
# @param [String] id ID
|
87
|
+
# @param [String] description 内容
|
88
|
+
# @param [String] note 正誤訂正(zakuro)
|
89
|
+
#
|
90
|
+
def initialize(id: '', description: '', note: '')
|
91
|
+
@id = id
|
92
|
+
@description = description
|
93
|
+
@note = note
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# 無効か
|
98
|
+
#
|
99
|
+
# @return [True] 無効
|
100
|
+
# @return [False] 有効
|
101
|
+
#
|
102
|
+
def invalid?
|
103
|
+
return true if @id == ''
|
104
|
+
|
105
|
+
@description == '' && @note == ''
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Reference 参照
|
111
|
+
#
|
112
|
+
class Reference
|
113
|
+
# @return [Integer] 頁数
|
114
|
+
attr_reader :page
|
115
|
+
# @return [Integer] 注釈番号
|
116
|
+
attr_reader :number
|
117
|
+
# @return [String] 和暦日
|
118
|
+
attr_reader :japan_date
|
119
|
+
|
120
|
+
#
|
121
|
+
# 初期化
|
122
|
+
#
|
123
|
+
# @param [Integer] page 頁数
|
124
|
+
# @param [Integer] number 注釈番号
|
125
|
+
# @param [String] japan_date 和暦日
|
126
|
+
#
|
127
|
+
def initialize(page: -1, number: -1, japan_date: '')
|
128
|
+
@page = page
|
129
|
+
@number = number
|
130
|
+
@japan_date = japan_date
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# 無効か
|
135
|
+
#
|
136
|
+
# @return [True] 無効
|
137
|
+
# @return [False] 有効
|
138
|
+
#
|
139
|
+
def invalid?
|
140
|
+
page == -1
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
#
|
145
|
+
# Diffs 総差分
|
146
|
+
#
|
147
|
+
class Diffs
|
148
|
+
# @return [Month] 月差分
|
149
|
+
attr_reader :month
|
150
|
+
# @return [SolarTerm::Direction] 二十四節気差分
|
151
|
+
attr_reader :solar_term
|
152
|
+
# @return [Integer] 日差分
|
153
|
+
attr_reader :days
|
154
|
+
|
155
|
+
#
|
156
|
+
# 初期化
|
157
|
+
#
|
158
|
+
# @param [Month] month 月差分
|
159
|
+
# @param [SolarTerm::Direction] solar_term 二十四節気差分
|
160
|
+
# @param [Integer] days 日差分
|
161
|
+
#
|
162
|
+
def initialize(month: Month.new, solar_term: SolarTerm::Direction.new,
|
163
|
+
days: INVALID_DAY_VALUE)
|
164
|
+
@month = month
|
165
|
+
@solar_term = solar_term
|
166
|
+
@days = days
|
167
|
+
end
|
168
|
+
|
169
|
+
#
|
170
|
+
# 日差分が無効か
|
171
|
+
#
|
172
|
+
# @return [True] 無効
|
173
|
+
# @return [False] 有効
|
174
|
+
#
|
175
|
+
def invalid_days?
|
176
|
+
@days == INVALID_DAY_VALUE
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
#
|
181
|
+
# Month 月差分
|
182
|
+
#
|
183
|
+
class Month
|
184
|
+
# @return [Number] 月
|
185
|
+
attr_reader :number
|
186
|
+
# @return [Leaped] 閏有無
|
187
|
+
attr_reader :leaped
|
188
|
+
# @return [Days] 月の大小
|
189
|
+
attr_reader :is_many_days
|
190
|
+
|
191
|
+
# :reek:BooleanParameter
|
192
|
+
|
193
|
+
#
|
194
|
+
# 初期化
|
195
|
+
#
|
196
|
+
# @param [Number] number 月
|
197
|
+
# @param [Leaped] leaped 閏有無
|
198
|
+
# @param [Days] days 月の大小
|
199
|
+
#
|
200
|
+
def initialize(number: Number.new, leaped: Leaped.new, is_many_days: Days.new)
|
201
|
+
@number = number
|
202
|
+
@leaped = leaped
|
203
|
+
@is_many_days = is_many_days
|
204
|
+
end
|
205
|
+
|
206
|
+
#
|
207
|
+
# 無効か
|
208
|
+
#
|
209
|
+
# @return [True] 無効
|
210
|
+
# @return [False] 有効
|
211
|
+
#
|
212
|
+
def invalid?
|
213
|
+
number == -1
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
#
|
218
|
+
# 二十四節気
|
219
|
+
#
|
220
|
+
module SolarTerm
|
221
|
+
#
|
222
|
+
# Direction 二十四節気(移動)
|
223
|
+
#
|
224
|
+
class Direction
|
225
|
+
# @return [Source] 二十四節気(移動元)
|
226
|
+
attr_reader :source
|
227
|
+
# @return [Destination] 二十四節気(移動先)
|
228
|
+
attr_reader :destination
|
229
|
+
# @return [Integer] 大余差分
|
230
|
+
attr_reader :days
|
231
|
+
|
232
|
+
#
|
233
|
+
# 初期化
|
234
|
+
#
|
235
|
+
# @param [Source] source 二十四節気(移動元)
|
236
|
+
# @param [Destination] destination 二十四節気(移動先)
|
237
|
+
# @param [Integer] day 大余差分
|
238
|
+
#
|
239
|
+
def initialize(source: Source.new, destination: Destination.new,
|
240
|
+
days: INVALID_DAY_VALUE)
|
241
|
+
@source = source
|
242
|
+
@destination = destination
|
243
|
+
@days = days
|
244
|
+
end
|
245
|
+
|
246
|
+
#
|
247
|
+
# 無効か(大余差分)
|
248
|
+
#
|
249
|
+
# @return [True] 無効
|
250
|
+
# @return [False] 有効
|
251
|
+
#
|
252
|
+
def invalid_days?
|
253
|
+
@days == INVALID_DAY_VALUE
|
254
|
+
end
|
255
|
+
|
256
|
+
#
|
257
|
+
# 無効か
|
258
|
+
#
|
259
|
+
# @return [True] 無効
|
260
|
+
# @return [False] 有効
|
261
|
+
#
|
262
|
+
def invalid?
|
263
|
+
@source.invalid? && @destination.invalid?
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
#
|
268
|
+
# Source 二十四節気(移動元)
|
269
|
+
#
|
270
|
+
class Source
|
271
|
+
# @return [Integer] 二十四節気番号
|
272
|
+
attr_reader :index
|
273
|
+
# @return [Western::Calendar] 移動先の月初日
|
274
|
+
attr_reader :to
|
275
|
+
# @return [String] 十干十二支
|
276
|
+
attr_reader :zodiac_name
|
277
|
+
|
278
|
+
#
|
279
|
+
# 初期化
|
280
|
+
#
|
281
|
+
# @param [Integer] index 二十四節気番号
|
282
|
+
# @param [Western::Calendar] to 移動先の月初日
|
283
|
+
# @param [String] zodiac_name 十干十二支
|
284
|
+
#
|
285
|
+
def initialize(index: -1, to: Western::Calendar.new, zodiac_name: '')
|
286
|
+
@index = index
|
287
|
+
@to = to
|
288
|
+
@zodiac_name = zodiac_name
|
289
|
+
end
|
290
|
+
|
291
|
+
#
|
292
|
+
# 無効か
|
293
|
+
#
|
294
|
+
# @return [True] 無効
|
295
|
+
# @return [False] 有効
|
296
|
+
#
|
297
|
+
def invalid?
|
298
|
+
@index == -1
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
#
|
303
|
+
# Destination 二十四節気(移動先)
|
304
|
+
#
|
305
|
+
class Destination
|
306
|
+
# @return [Integer] 二十四節気番号
|
307
|
+
attr_reader :index
|
308
|
+
# @return [Western::Calendar] 移動元の月初日
|
309
|
+
attr_reader :from
|
310
|
+
# @return [String] 十干十二支
|
311
|
+
attr_reader :zodiac_name
|
312
|
+
|
313
|
+
#
|
314
|
+
# 初期化
|
315
|
+
#
|
316
|
+
# @param [Integer] index 二十四節気番号
|
317
|
+
# @param [Western::Calendar] from 移動元の月初日
|
318
|
+
# @param [String] zodiac_name 十干十二支
|
319
|
+
#
|
320
|
+
def initialize(index: -1, from: Western::Calendar.new, zodiac_name: '')
|
321
|
+
@index = index
|
322
|
+
@from = from
|
323
|
+
@zodiac_name = zodiac_name
|
324
|
+
end
|
325
|
+
|
326
|
+
#
|
327
|
+
# 無効か
|
328
|
+
#
|
329
|
+
# @return [True] 無効
|
330
|
+
# @return [False] 有効
|
331
|
+
#
|
332
|
+
def invalid?
|
333
|
+
@index == -1
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
#
|
339
|
+
# Number 月
|
340
|
+
#
|
341
|
+
class Number
|
342
|
+
# @return [Integer] 計算
|
343
|
+
attr_reader :calc
|
344
|
+
# @return [Integer] 運用
|
345
|
+
attr_reader :actual
|
346
|
+
|
347
|
+
#
|
348
|
+
# 初期化
|
349
|
+
#
|
350
|
+
# @param [Integer] calc 計算
|
351
|
+
# @param [Integer] actual 運用
|
352
|
+
#
|
353
|
+
def initialize(calc: -1, actual: -1)
|
354
|
+
@calc = calc
|
355
|
+
@actual = actual
|
356
|
+
end
|
357
|
+
|
358
|
+
#
|
359
|
+
# 無効か
|
360
|
+
#
|
361
|
+
# @return [True] 無効
|
362
|
+
# @return [False] 有効
|
363
|
+
#
|
364
|
+
def invalid?
|
365
|
+
@calc == -1 || @actual == -1
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
#
|
370
|
+
# Leaped 閏有無
|
371
|
+
#
|
372
|
+
class Leaped
|
373
|
+
# @return [True, False] 計算
|
374
|
+
attr_reader :calc
|
375
|
+
# @return [True, False] 運用
|
376
|
+
attr_reader :actual
|
377
|
+
|
378
|
+
# :reek:BooleanParameter
|
379
|
+
|
380
|
+
#
|
381
|
+
# 初期化
|
382
|
+
#
|
383
|
+
# @param [True, False] calc 計算
|
384
|
+
# @param [True, False] actual 運用
|
385
|
+
#
|
386
|
+
def initialize(calc: false, actual: false)
|
387
|
+
@calc = calc
|
388
|
+
@actual = actual
|
389
|
+
end
|
390
|
+
|
391
|
+
#
|
392
|
+
# 無効か
|
393
|
+
#
|
394
|
+
# @return [True] 無効(設定値なし)
|
395
|
+
# @return [False] 有効
|
396
|
+
#
|
397
|
+
def invalid?
|
398
|
+
!@calc && !@actual
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
#
|
403
|
+
# Days 月大小
|
404
|
+
#
|
405
|
+
class Days
|
406
|
+
# @return [String] 29日
|
407
|
+
SMALL = '小'
|
408
|
+
# @return [String] 30日
|
409
|
+
BIG = '大'
|
410
|
+
|
411
|
+
#
|
412
|
+
# 初期化
|
413
|
+
#
|
414
|
+
# @param [String] calc 計算
|
415
|
+
# @param [String] actual 運用
|
416
|
+
#
|
417
|
+
def initialize(calc: '小', actual: '小')
|
418
|
+
@calc = calc
|
419
|
+
@actual = actual
|
420
|
+
end
|
421
|
+
|
422
|
+
#
|
423
|
+
# 計算値が大か
|
424
|
+
#
|
425
|
+
# @return [True] 大
|
426
|
+
# @return [False] 小
|
427
|
+
#
|
428
|
+
def calc
|
429
|
+
@calc == BIG
|
430
|
+
end
|
431
|
+
|
432
|
+
#
|
433
|
+
# 運用値が大か
|
434
|
+
#
|
435
|
+
# @return [True] 大
|
436
|
+
# @return [False] 小
|
437
|
+
#
|
438
|
+
def actual
|
439
|
+
@actual == BIG
|
440
|
+
end
|
441
|
+
|
442
|
+
#
|
443
|
+
# 無効か
|
444
|
+
#
|
445
|
+
# @return [True] 無効(差分なし/設定値なし)
|
446
|
+
# @return [False] 有効
|
447
|
+
#
|
448
|
+
def invalid?
|
449
|
+
@calc == @actual
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
end
|