zakuro 0.9.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/README.md +41 -8
- data/VERSION +1 -1
- data/doc/gengou.md +1 -1
- data/doc/operation/csv/month.csv +5 -5
- data/doc/operation/operation.xlsx +0 -0
- data/images/logo-text.png +0 -0
- data/lib/zakuro/calculation/base/gengou.rb +2 -4
- data/lib/zakuro/calculation/base/year.rb +1 -1
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +2 -2
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +1 -1
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +4 -4
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +1 -1
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +3 -3
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +1 -1
- data/lib/zakuro/calculation/monthly/internal/date_comparer.rb +78 -0
- data/lib/zakuro/calculation/monthly/{meta → internal/meta}/all_solar_term.rb +1 -1
- data/lib/zakuro/calculation/monthly/{meta → internal/meta}/meta_collector.rb +2 -2
- data/lib/zakuro/calculation/monthly/{first_day.rb → internal/part/first_day.rb} +2 -2
- data/lib/zakuro/calculation/monthly/{meta.rb → internal/part/meta.rb} +1 -1
- data/lib/zakuro/calculation/monthly/internal/solar_term_selector.rb +203 -0
- data/lib/zakuro/calculation/monthly/month.rb +30 -125
- data/lib/zakuro/calculation/monthly/operated_month.rb +5 -2
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +0 -2
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +24 -10
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +3 -3
- data/lib/zakuro/calculation/summary/internal/option/dropped_date.rb +102 -0
- data/lib/zakuro/calculation/summary/internal/option/vanished_date.rb +111 -0
- data/lib/zakuro/calculation/summary/internal/option.rb +4 -137
- data/lib/zakuro/calculation/summary/japan/range.rb +4 -5
- data/lib/zakuro/calculation/summary/western/single.rb +0 -2
- data/lib/zakuro/context/version_class_resolver.rb +5 -5
- data/lib/zakuro/era/japan/calendar.rb +4 -4
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +2 -2
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +2 -2
- data/lib/zakuro/era/japan/gengou/alignment.rb +5 -3
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +17 -16
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +3 -394
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +2 -2
- data/lib/zakuro/era/japan/gengou.rb +3 -3
- data/lib/zakuro/era/japan/type/base/both/date.rb +51 -0
- data/lib/zakuro/era/japan/type/base/both/year.rb +53 -0
- data/lib/zakuro/era/japan/type/base/gengou.rb +177 -0
- data/lib/zakuro/era/japan/type/base/gengou_set.rb +78 -0
- data/lib/zakuro/era/japan/type/base/switch_date.rb +74 -0
- data/lib/zakuro/era/japan/type/base/version_range.rb +189 -0
- data/lib/zakuro/era/japan/type/validation/both/date.rb +99 -0
- data/lib/zakuro/era/japan/type/validation/both/year.rb +75 -0
- data/lib/zakuro/era/japan/type/validation/gengou.rb +93 -0
- data/lib/zakuro/era/japan/type/validation/gengou_set.rb +133 -0
- data/lib/zakuro/era/japan/type/validation/switch_date.rb +73 -0
- data/lib/zakuro/era/japan/type/validation/version_range.rb +109 -0
- data/lib/zakuro/era/japan/type/validation/version_root.rb +102 -0
- data/lib/zakuro/era/japan/version/resource/parser.rb +266 -0
- data/lib/zakuro/era/japan/version/resource/validator.rb +37 -0
- data/lib/zakuro/era/japan/version/resource/yaml/version.yaml +80 -0
- data/lib/zakuro/era/japan/version/resource.rb +22 -0
- data/lib/zakuro/era/japan/version.rb +4 -115
- data/lib/zakuro/era/western/calendar.rb +2 -2
- data/lib/zakuro/exception/zakuro_error.rb +1 -1
- data/lib/zakuro/merchant.rb +5 -5
- data/lib/zakuro/operation/month/parser.rb +2 -2
- data/lib/zakuro/operation/yaml/month.yaml +5 -5
- data/lib/zakuro/output/logger.rb +4 -4
- data/lib/zakuro/parameter/catalog/basis_date.rb +55 -0
- data/lib/zakuro/parameter/catalog/column.rb +57 -0
- data/lib/zakuro/parameter/catalog/option.rb +60 -0
- data/lib/zakuro/parameter/catalog/range.rb +81 -0
- data/lib/zakuro/parameter/condition.rb +108 -0
- data/lib/zakuro/result/core.rb +2 -2
- data/lib/zakuro/{tools → tool}/remainder_comparer.rb +2 -4
- data/lib/zakuro/{tools → tool}/stringifier.rb +3 -3
- data/lib/zakuro/{tools → tool}/typeconv.rb +2 -2
- data/lib/zakuro/{tools → tool}/typeof.rb +2 -2
- data/lib/zakuro/version/daien/const/number.rb +42 -39
- data/lib/zakuro/version/daien/const/remainder.rb +38 -35
- data/lib/zakuro/version/daien/cycle/remainder.rb +77 -74
- data/lib/zakuro/version/daien/cycle/solar_term.rb +18 -15
- data/lib/zakuro/version/daien/daien.rb +8 -5
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +67 -64
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +15 -12
- data/lib/zakuro/version/daien/option/vanished_date/parameter.rb +15 -12
- data/lib/zakuro/version/daien/range/annual_range.rb +27 -24
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +209 -206
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +32 -29
- data/lib/zakuro/version/daien/stella/lunar/location.rb +53 -50
- data/lib/zakuro/version/daien/stella/lunar/value.rb +65 -62
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +23 -20
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +42 -39
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +44 -41
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +74 -71
- data/lib/zakuro/version/daien/stella/solar/average.rb +68 -65
- data/lib/zakuro/version/daien/stella/solar/interval.rb +95 -92
- data/lib/zakuro/version/daien/stella/solar/location.rb +41 -38
- data/lib/zakuro/version/daien/stella/solar/value.rb +21 -18
- data/lib/zakuro/version/genka/const/number.rb +31 -28
- data/lib/zakuro/version/genka/const/remainder.rb +20 -17
- data/lib/zakuro/version/genka/cycle/remainder.rb +72 -69
- data/lib/zakuro/version/genka/cycle/solar_term.rb +18 -15
- data/lib/zakuro/version/genka/genka.rb +8 -5
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +82 -79
- data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +13 -10
- data/lib/zakuro/version/genka/option/vanished_date/parameter.rb +13 -10
- data/lib/zakuro/version/genka/range/annual_range.rb +57 -54
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +44 -41
- data/lib/zakuro/version/genka/stella/origin/january.rb +38 -35
- data/lib/zakuro/version/genka/stella/solar/average.rb +24 -21
- data/lib/zakuro/version/gihou/const/number.rb +40 -37
- data/lib/zakuro/version/gihou/const/remainder.rb +32 -29
- data/lib/zakuro/version/gihou/cycle/remainder.rb +38 -35
- data/lib/zakuro/version/gihou/cycle/solar_term.rb +18 -15
- data/lib/zakuro/version/gihou/gihou.rb +8 -5
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +68 -65
- data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +13 -10
- data/lib/zakuro/version/gihou/option/vanished_date/parameter.rb +13 -10
- data/lib/zakuro/version/gihou/range/annual_range.rb +27 -24
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +212 -209
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +32 -29
- data/lib/zakuro/version/gihou/stella/lunar/location.rb +53 -50
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +65 -62
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +23 -20
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +42 -39
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +44 -41
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +74 -71
- data/lib/zakuro/version/gihou/stella/solar/average.rb +67 -64
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +95 -92
- data/lib/zakuro/version/gihou/stella/solar/location.rb +41 -38
- data/lib/zakuro/version/gihou/stella/solar/value.rb +21 -18
- data/lib/zakuro/version/gregorio/gregorio.rb +8 -5
- data/lib/zakuro/version/houryaku/houryaku.rb +8 -5
- data/lib/zakuro/version/joukyou/joukyou.rb +8 -5
- data/lib/zakuro/version/kansei/kansei.rb +8 -5
- data/lib/zakuro/version/senmyou/const/number.rb +40 -37
- data/lib/zakuro/version/senmyou/const/remainder.rb +35 -32
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +74 -71
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +18 -15
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +69 -66
- data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +15 -12
- data/lib/zakuro/version/senmyou/option/vanished_date/parameter.rb +15 -12
- data/lib/zakuro/version/senmyou/range/annual_range.rb +27 -24
- data/lib/zakuro/version/senmyou/senmyou.rb +8 -5
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +206 -203
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +32 -29
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +60 -57
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +66 -63
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +23 -20
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +42 -39
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +44 -41
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +74 -71
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +67 -64
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +93 -90
- data/lib/zakuro/version/senmyou/stella/solar/location.rb +41 -38
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +23 -20
- data/lib/zakuro/version/tenpou/tenpou.rb +8 -5
- metadata +44 -20
- data/lib/zakuro/condition.rb +0 -306
- data/lib/zakuro/era/japan/gengou/resource/type.rb +0 -356
- data/lib/zakuro/tools/gengou_range_comparer.rb +0 -82
- /data/lib/zakuro/calculation/monthly/{operated_solar_term.rb → internal/operated_solar_term.rb} +0 -0
- /data/lib/zakuro/calculation/monthly/{const.rb → internal/part/const.rb} +0 -0
- /data/lib/zakuro/calculation/monthly/{month_label.rb → internal/part/month_label.rb} +0 -0
@@ -5,238 +5,241 @@ require_relative '../../const/number'
|
|
5
5
|
# :nodoc:
|
6
6
|
module Zakuro
|
7
7
|
# :nodoc:
|
8
|
-
module
|
8
|
+
module Version
|
9
9
|
# :nodoc:
|
10
|
-
module
|
11
|
-
#
|
12
|
-
|
13
|
-
#
|
14
|
-
module Adjustment
|
15
|
-
# 『歴代天文律暦等志彙編 七』中華書房 p.2230
|
10
|
+
module Daien
|
11
|
+
# :nodoc:
|
12
|
+
module Lunar
|
16
13
|
#
|
17
|
-
#
|
14
|
+
# Adjustment 補正値情報
|
18
15
|
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
module Adjustment
|
17
|
+
# 『歴代天文律暦等志彙編 七』中華書房 p.2230
|
18
|
+
#
|
19
|
+
# 遠/近の地点での中間
|
20
|
+
#
|
21
|
+
# @return [Hash<Integer>] 遠/近の地点での中間
|
22
|
+
DAY_LIMIT = {
|
23
|
+
7 => 2701,
|
24
|
+
14 => 2363,
|
25
|
+
21 => 2024,
|
26
|
+
28 => 1686
|
27
|
+
}.freeze
|
28
|
+
|
29
|
+
#
|
30
|
+
# Row 行情報
|
31
|
+
#
|
32
|
+
class Row
|
33
|
+
# @return [Integer] 入暦(1-14)
|
34
|
+
attr_reader :day
|
35
|
+
# @return [Range] 小余範囲
|
36
|
+
attr_reader :range
|
37
|
+
# @return [Value] 補正値
|
38
|
+
attr_reader :value
|
39
|
+
|
40
|
+
#
|
41
|
+
# 初期化
|
42
|
+
#
|
43
|
+
# @param [Integer] day 入暦(1-14)
|
44
|
+
# @param [Range] range 小余範囲
|
45
|
+
# @param [Value] value 補正値
|
46
|
+
#
|
47
|
+
def initialize(day:, range:, value:)
|
48
|
+
@day = day
|
49
|
+
@range = range
|
50
|
+
@value = value
|
51
|
+
end
|
26
52
|
|
27
|
-
|
28
|
-
# Row 行情報
|
29
|
-
#
|
30
|
-
class Row
|
31
|
-
# @return [Integer] 入暦(1-14)
|
32
|
-
attr_reader :day
|
33
|
-
# @return [Range] 小余範囲
|
34
|
-
attr_reader :range
|
35
|
-
# @return [Value] 補正値
|
36
|
-
attr_reader :value
|
53
|
+
# :reek:ControlParameter
|
37
54
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
55
|
+
#
|
56
|
+
# 一致するか
|
57
|
+
#
|
58
|
+
# @param [Integer] day 入暦(1-14)
|
59
|
+
# @param [Integer] minute 小余
|
60
|
+
#
|
61
|
+
# @return [True] 一致
|
62
|
+
# @return [False] 不一致
|
63
|
+
#
|
64
|
+
def match?(day:, minute:)
|
65
|
+
inner_day = @day
|
66
|
+
return false unless inner_day == day
|
50
67
|
|
51
|
-
|
68
|
+
return false unless range.include?(minute: minute)
|
52
69
|
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
# @param [Integer] day 入暦(1-14)
|
57
|
-
# @param [Integer] minute 小余
|
58
|
-
#
|
59
|
-
# @return [True] 一致
|
60
|
-
# @return [False] 不一致
|
61
|
-
#
|
62
|
-
def match?(day:, minute:)
|
63
|
-
inner_day = @day
|
64
|
-
return false unless inner_day == day
|
65
|
-
|
66
|
-
return false unless range.include?(minute: minute)
|
70
|
+
true
|
71
|
+
end
|
67
72
|
|
68
|
-
|
73
|
+
#
|
74
|
+
# 分母を返す
|
75
|
+
#
|
76
|
+
# @return [Integer] 分母
|
77
|
+
#
|
78
|
+
def denominator
|
79
|
+
range.denominator
|
80
|
+
end
|
69
81
|
end
|
70
82
|
|
71
83
|
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
# Range 小余範囲
|
85
|
+
#
|
86
|
+
class Range
|
87
|
+
# @return [Integer] 下限
|
88
|
+
MIN = 0
|
89
|
+
# @return [Integer] 上限
|
90
|
+
MAX = Const::Number::Cycle::DAY
|
91
|
+
|
92
|
+
# @return [Integer] 下限
|
93
|
+
attr_reader :min
|
94
|
+
# @return [Integer] 上限
|
95
|
+
attr_reader :max
|
96
|
+
|
97
|
+
#
|
98
|
+
# 初期化
|
99
|
+
#
|
100
|
+
# @param [Integer] min 下限
|
101
|
+
# @param [Integer] max 上限
|
102
|
+
#
|
103
|
+
def initialize(min: MIN, max: MAX)
|
104
|
+
@min = min
|
105
|
+
@max = max
|
106
|
+
end
|
89
107
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
108
|
+
#
|
109
|
+
# 含まれるか
|
110
|
+
#
|
111
|
+
# @param [Integer] minute 小余
|
112
|
+
#
|
113
|
+
# @return [True] 含まれる
|
114
|
+
# @return [False] 含まれない
|
115
|
+
#
|
116
|
+
def include?(minute:)
|
117
|
+
minute >= min && minute <= max
|
118
|
+
end
|
94
119
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
@max = max
|
120
|
+
#
|
121
|
+
# 分母を返す
|
122
|
+
#
|
123
|
+
# @return [Integer] 分母
|
124
|
+
#
|
125
|
+
def denominator
|
126
|
+
max - min
|
127
|
+
end
|
104
128
|
end
|
105
129
|
|
106
130
|
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# @param [Integer] minute 小余
|
110
|
-
#
|
111
|
-
# @return [True] 含まれる
|
112
|
-
# @return [False] 含まれない
|
131
|
+
# Value 補正値
|
113
132
|
#
|
114
|
-
|
115
|
-
|
116
|
-
|
133
|
+
class Value
|
134
|
+
# @return [Integer] 増減率
|
135
|
+
attr_reader :per
|
136
|
+
# @return [Integer] 遅速積
|
137
|
+
attr_reader :stack
|
117
138
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
#
|
129
|
-
# Value 補正値
|
130
|
-
#
|
131
|
-
class Value
|
132
|
-
# @return [Integer] 増減率
|
133
|
-
attr_reader :per
|
134
|
-
# @return [Integer] 遅速積
|
135
|
-
attr_reader :stack
|
136
|
-
|
137
|
-
#
|
138
|
-
# 初期化
|
139
|
-
#
|
140
|
-
# @param [Integer] per 増減率
|
141
|
-
# @param [Integer] stack 遅速積
|
142
|
-
#
|
143
|
-
def initialize(per:, stack:)
|
144
|
-
@per = per
|
145
|
-
@stack = stack
|
146
|
-
end
|
139
|
+
#
|
140
|
+
# 初期化
|
141
|
+
#
|
142
|
+
# @param [Integer] per 増減率
|
143
|
+
# @param [Integer] stack 遅速積
|
144
|
+
#
|
145
|
+
def initialize(per:, stack:)
|
146
|
+
@per = per
|
147
|
+
@stack = stack
|
148
|
+
end
|
147
149
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
150
|
+
#
|
151
|
+
# 文字化
|
152
|
+
#
|
153
|
+
# @return [String] 文字
|
154
|
+
#
|
155
|
+
def to_s
|
156
|
+
"per:#{per}, stack:#{stack}"
|
157
|
+
end
|
155
158
|
end
|
156
|
-
end
|
157
159
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
160
|
+
# rubocop:disable Layout/LineLength
|
161
|
+
|
162
|
+
# 『歴代天文律暦等志彙編 七』中華書房 p.2228-2230
|
163
|
+
#
|
164
|
+
# @note 7日、14日、21日、28日の小余は DAY_LIMIT を参照のこと
|
165
|
+
#
|
166
|
+
# @return [Array<Row>] 月の補正値情報
|
167
|
+
#
|
168
|
+
LIST = [
|
169
|
+
Row.new(day: 1, range: Range.new, value: Value.new(per: +297, stack: 0)),
|
170
|
+
Row.new(day: 2, range: Range.new, value: Value.new(per: +259, stack: +297)),
|
171
|
+
Row.new(day: 3, range: Range.new, value: Value.new(per: +220, stack: +556)),
|
172
|
+
Row.new(day: 4, range: Range.new, value: Value.new(per: +180, stack: +776)),
|
173
|
+
Row.new(day: 5, range: Range.new, value: Value.new(per: +139, stack: +956)),
|
174
|
+
Row.new(day: 6, range: Range.new, value: Value.new(per: +97, stack: +1095)),
|
175
|
+
Row.new(day: 7, range: Range.new(max: DAY_LIMIT[7]), value: Value.new(per: +48, stack: +1192)),
|
176
|
+
Row.new(day: 7, range: Range.new(min: DAY_LIMIT[7]), value: Value.new(per: -6, stack: +1240)), # stack: +1192 + 48
|
177
|
+
Row.new(day: 8, range: Range.new, value: Value.new(per: -64, stack: +1234)),
|
178
|
+
Row.new(day: 9, range: Range.new, value: Value.new(per: -106, stack: +1170)),
|
179
|
+
Row.new(day: 10, range: Range.new, value: Value.new(per: -148, stack: +1064)),
|
180
|
+
Row.new(day: 11, range: Range.new, value: Value.new(per: -189, stack: +916)),
|
181
|
+
Row.new(day: 12, range: Range.new, value: Value.new(per: -229, stack: +727)),
|
182
|
+
Row.new(day: 13, range: Range.new, value: Value.new(per: -267, stack: +498)),
|
183
|
+
Row.new(day: 14, range: Range.new(max: DAY_LIMIT[14]), value: Value.new(per: -231, stack: +231)),
|
184
|
+
Row.new(day: 14, range: Range.new(min: DAY_LIMIT[14]), value: Value.new(per: -66, stack: 0)), # stack: +232 - 231
|
185
|
+
Row.new(day: 15, range: Range.new, value: Value.new(per: -289, stack: -66)),
|
186
|
+
Row.new(day: 16, range: Range.new, value: Value.new(per: -250, stack: -355)),
|
187
|
+
Row.new(day: 17, range: Range.new, value: Value.new(per: -211, stack: -605)),
|
188
|
+
Row.new(day: 18, range: Range.new, value: Value.new(per: -171, stack: -816)),
|
189
|
+
Row.new(day: 19, range: Range.new, value: Value.new(per: -130, stack: -987)),
|
190
|
+
Row.new(day: 20, range: Range.new, value: Value.new(per: -87, stack: -1117)),
|
191
|
+
Row.new(day: 21, range: Range.new(max: DAY_LIMIT[21]), value: Value.new(per: -36, stack: -1204)),
|
192
|
+
Row.new(day: 21, range: Range.new(min: DAY_LIMIT[21]), value: Value.new(per: +18, stack: -1240)), # stack: -1204 - 36
|
193
|
+
Row.new(day: 22, range: Range.new, value: Value.new(per: +73, stack: -1222)),
|
194
|
+
Row.new(day: 23, range: Range.new, value: Value.new(per: +116, stack: -1149)),
|
195
|
+
Row.new(day: 24, range: Range.new, value: Value.new(per: +157, stack: -1033)),
|
196
|
+
Row.new(day: 25, range: Range.new, value: Value.new(per: +198, stack: -876)),
|
197
|
+
Row.new(day: 26, range: Range.new, value: Value.new(per: +237, stack: -678)),
|
198
|
+
Row.new(day: 27, range: Range.new, value: Value.new(per: +276, stack: -441)),
|
199
|
+
Row.new(day: 28, range: Range.new(max: DAY_LIMIT[28]), value: Value.new(per: +165, stack: -165))
|
200
|
+
].freeze
|
201
|
+
# rubocop:enable Layout/LineLength
|
202
|
+
|
203
|
+
class << self
|
204
|
+
#
|
205
|
+
# 月軌道の補正に必要な基本値を引き当てる
|
206
|
+
#
|
207
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
208
|
+
# @param [Integer] day 大余
|
209
|
+
# @param [Integer] minute 小余
|
210
|
+
#
|
211
|
+
# @return [Row] 補正値
|
212
|
+
#
|
213
|
+
# @raise [ArgumentError] 引数エラー
|
214
|
+
#
|
215
|
+
def specify(day:, minute:)
|
216
|
+
LIST.each do |row|
|
217
|
+
# NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
|
218
|
+
return row if row.match?(day: day, minute: minute)
|
219
|
+
end
|
220
|
+
|
221
|
+
raise ArgumentError.new, "invalid parameter: #{day}/#{minute}"
|
217
222
|
end
|
218
223
|
|
219
|
-
|
220
|
-
end
|
221
|
-
|
222
|
-
# :reek:ControlParameter
|
224
|
+
# :reek:ControlParameter
|
223
225
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
226
|
+
#
|
227
|
+
# 小余の下げ幅を求める
|
228
|
+
#
|
229
|
+
# @param [Integer] day 大余
|
230
|
+
# @param [Integer] minute 小余
|
231
|
+
#
|
232
|
+
# @return [Integer] 小余の下げ幅
|
233
|
+
#
|
234
|
+
def minus_minute(day:, minute:)
|
235
|
+
limit = DAY_LIMIT.fetch(day, -1)
|
236
|
+
# 該当なし
|
237
|
+
return minute if limit == -1
|
236
238
|
|
237
|
-
|
239
|
+
return minute unless minute > limit
|
238
240
|
|
239
|
-
|
241
|
+
minute - limit
|
242
|
+
end
|
240
243
|
end
|
241
244
|
end
|
242
245
|
end
|
@@ -5,39 +5,42 @@ require_relative '../../const/number'
|
|
5
5
|
# :nodoc:
|
6
6
|
module Zakuro
|
7
7
|
# :nodoc:
|
8
|
-
module
|
8
|
+
module Version
|
9
9
|
# :nodoc:
|
10
|
-
module
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
module Daien
|
11
|
+
# :nodoc:
|
12
|
+
module Lunar
|
13
|
+
#
|
14
|
+
# Localization 入暦特定
|
15
|
+
#
|
16
|
+
module Localization
|
17
|
+
# @return [Integer] 1近点月
|
18
|
+
ANOMALISTIC_MONTH = Const::Number::Cycle::ANOMALISTIC_MONTH
|
19
|
+
# @return [Integer] 積年
|
20
|
+
TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
|
21
|
+
# @return [Integer] 開始年
|
22
|
+
BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
|
23
|
+
# @return [Integer] 年
|
24
|
+
YEAR = Const::Number::Cycle::YEAR
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
class << self
|
27
|
+
#
|
28
|
+
# 対象年の最初の入暦を求める
|
29
|
+
#
|
30
|
+
# @param [Remainder] lunar_age 天正閏余
|
31
|
+
# @param [Integer] western_year 西暦年
|
32
|
+
#
|
33
|
+
# @return [Cycle::LunarRemainder] 入暦
|
34
|
+
#
|
35
|
+
def first_remainder(lunar_age:, western_year:)
|
36
|
+
# 積年の開始から対象年までの年数
|
37
|
+
total_year = TOTAL_YEAR + western_year - BEGIN_YEAR
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
# 通積分 - 天正閏余
|
40
|
+
total_day = total_year * YEAR - lunar_age.to_minute
|
39
41
|
|
40
|
-
|
42
|
+
Cycle::LunarRemainder.new(total: (total_day % ANOMALISTIC_MONTH))
|
43
|
+
end
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -9,67 +9,70 @@ require_relative './localization'
|
|
9
9
|
# :nodoc:
|
10
10
|
module Zakuro
|
11
11
|
# :nodoc:
|
12
|
-
module
|
12
|
+
module Version
|
13
13
|
# :nodoc:
|
14
|
-
module
|
15
|
-
#
|
16
|
-
|
17
|
-
#
|
18
|
-
class Location < Calculation::Lunar::AbstractLocation
|
19
|
-
# @return [Cycle::LunarRemainder] 1近点月
|
20
|
-
ANOMALISTIC_MONTH = Const::Remainder::Lunar::ANOMALISTIC_MONTH
|
21
|
-
# @return [Cycle::LunarRemainder] 弦
|
22
|
-
QUARTER = Const::Remainder::Lunar::QUARTER
|
23
|
-
|
24
|
-
#
|
25
|
-
# 初期化
|
14
|
+
module Daien
|
15
|
+
# :nodoc:
|
16
|
+
module Lunar
|
26
17
|
#
|
27
|
-
#
|
28
|
-
# @param [Integer] western_year 西暦年
|
18
|
+
# Location 入暦
|
29
19
|
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
)
|
36
|
-
end
|
20
|
+
class Location < Calculation::Lunar::AbstractLocation
|
21
|
+
# @return [Cycle::LunarRemainder] 1近点月
|
22
|
+
ANOMALISTIC_MONTH = Const::Remainder::Lunar::ANOMALISTIC_MONTH
|
23
|
+
# @return [Cycle::LunarRemainder] 弦
|
24
|
+
QUARTER = Const::Remainder::Lunar::QUARTER
|
37
25
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
26
|
+
#
|
27
|
+
# 初期化
|
28
|
+
#
|
29
|
+
# @param [Cycle::LunarRemainder] lunar_age 天正閏余(大余小余)
|
30
|
+
# @param [Integer] western_year 西暦年
|
31
|
+
#
|
32
|
+
def initialize(lunar_age:, western_year:)
|
33
|
+
super(
|
34
|
+
lunar_age: lunar_age,
|
35
|
+
quarter: QUARTER,
|
36
|
+
western_year: western_year
|
37
|
+
)
|
45
38
|
end
|
46
39
|
|
47
|
-
|
48
|
-
|
40
|
+
#
|
41
|
+
# 入暦を計算する
|
42
|
+
#
|
43
|
+
def run
|
44
|
+
if calculated
|
45
|
+
decrease(limit: ANOMALISTIC_MONTH)
|
46
|
+
return
|
47
|
+
end
|
49
48
|
|
50
|
-
|
49
|
+
first
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
# 初回計算
|
54
|
-
#
|
55
|
-
def first
|
56
|
-
@remainder = Localization.first_remainder(
|
57
|
-
lunar_age: remainder, western_year: western_year
|
58
|
-
)
|
59
|
-
decrease(limit: ANOMALISTIC_MONTH)
|
52
|
+
private
|
60
53
|
|
61
|
-
|
62
|
-
|
54
|
+
#
|
55
|
+
# 初回計算
|
56
|
+
#
|
57
|
+
def first
|
58
|
+
@remainder = Localization.first_remainder(
|
59
|
+
lunar_age: remainder, western_year: western_year
|
60
|
+
)
|
61
|
+
decrease(limit: ANOMALISTIC_MONTH)
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
# @param [Cycle::LunarRemainder] limit 上限
|
68
|
-
#
|
69
|
-
def decrease(limit:)
|
70
|
-
return if remainder < limit
|
63
|
+
@calculated = true
|
64
|
+
end
|
71
65
|
|
72
|
-
|
66
|
+
#
|
67
|
+
# 大余小余に合わせて減算する(折り返す)
|
68
|
+
#
|
69
|
+
# @param [Cycle::LunarRemainder] limit 上限
|
70
|
+
#
|
71
|
+
def decrease(limit:)
|
72
|
+
return if remainder < limit
|
73
|
+
|
74
|
+
remainder.sub!(limit)
|
75
|
+
end
|
73
76
|
end
|
74
77
|
end
|
75
78
|
end
|