zakuro 0.9.3 → 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 +8 -9
- 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/cycle/abstract_solar_term.rb +6 -0
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +2 -2
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +4 -2
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +1 -1
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +13 -7
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +18 -9
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +6 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +5 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +12 -4
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +10 -4
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +5 -2
- 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 +38 -74
- data/lib/zakuro/calculation/monthly/operated_month.rb +7 -2
- data/lib/zakuro/calculation/option/dropped_date/location.rb +8 -1
- data/lib/zakuro/calculation/range/dated_full_range.rb +6 -3
- data/lib/zakuro/calculation/range/dated_operation_range.rb +2 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +0 -2
- data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
- 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/range.rb +8 -1
- data/lib/zakuro/calculation/summary/western/single.rb +10 -5
- 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 +35 -6
- 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 +8 -6
- 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 +8 -40
- 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 +3 -2
- 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 +40 -15
- data/lib/zakuro/condition.rb +0 -306
- data/lib/zakuro/era/japan/gengou/resource/type.rb +0 -356
- /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,236 +5,239 @@ 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
|
-
# @return [Integer] 遠/近の地点での中間
|
16
|
-
HALF_DAYS = [7].freeze
|
17
|
-
|
10
|
+
module Senmyou
|
11
|
+
# :nodoc:
|
12
|
+
module Lunar
|
18
13
|
#
|
19
|
-
#
|
14
|
+
# Adjustment 補正値情報
|
20
15
|
#
|
21
|
-
|
22
|
-
# @return [
|
23
|
-
|
24
|
-
|
25
|
-
#
|
26
|
-
|
27
|
-
#
|
28
|
-
|
29
|
-
|
30
|
-
|
16
|
+
module Adjustment
|
17
|
+
# @return [Integer] 遠/近の地点での中間
|
18
|
+
HALF_DAYS = [7].freeze
|
19
|
+
|
20
|
+
#
|
21
|
+
# Row 行情報
|
22
|
+
#
|
23
|
+
class Row
|
24
|
+
# @return [True] 進(遠地点より数える)
|
25
|
+
# @return [False] 退(近地点より数える)
|
26
|
+
attr_reader :forward
|
27
|
+
# @return [Integer] 入暦(1-14)
|
28
|
+
attr_reader :day
|
29
|
+
# @return [Range] 小余範囲
|
30
|
+
attr_reader :range
|
31
|
+
# @return [Value] 補正値
|
32
|
+
attr_reader :value
|
33
|
+
|
34
|
+
#
|
35
|
+
# 初期化
|
36
|
+
#
|
37
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
38
|
+
# @param [Integer] day 入暦(1-14)
|
39
|
+
# @param [Range] range 小余範囲
|
40
|
+
# @param [Value] value 補正値
|
41
|
+
#
|
42
|
+
def initialize(forward:, day:, range:, value:)
|
43
|
+
@forward = forward
|
44
|
+
@day = day
|
45
|
+
@range = range
|
46
|
+
@value = value
|
47
|
+
end
|
31
48
|
|
32
|
-
|
33
|
-
# 初期化
|
34
|
-
#
|
35
|
-
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
36
|
-
# @param [Integer] day 入暦(1-14)
|
37
|
-
# @param [Range] range 小余範囲
|
38
|
-
# @param [Value] value 補正値
|
39
|
-
#
|
40
|
-
def initialize(forward:, day:, range:, value:)
|
41
|
-
@forward = forward
|
42
|
-
@day = day
|
43
|
-
@range = range
|
44
|
-
@value = value
|
45
|
-
end
|
49
|
+
# :reek:ControlParameter
|
46
50
|
|
47
|
-
|
51
|
+
#
|
52
|
+
# 一致するか
|
53
|
+
#
|
54
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
55
|
+
# @param [Integer] day 入暦(1-14)
|
56
|
+
# @param [Integer] minute 小余
|
57
|
+
#
|
58
|
+
# @return [True] 一致
|
59
|
+
# @return [False] 不一致
|
60
|
+
#
|
61
|
+
def match?(forward:, day:, minute:)
|
62
|
+
inner_forward = @forward
|
63
|
+
return false unless inner_forward == forward
|
48
64
|
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
53
|
-
# @param [Integer] day 入暦(1-14)
|
54
|
-
# @param [Integer] minute 小余
|
55
|
-
#
|
56
|
-
# @return [True] 一致
|
57
|
-
# @return [False] 不一致
|
58
|
-
#
|
59
|
-
def match?(forward:, day:, minute:)
|
60
|
-
inner_forward = @forward
|
61
|
-
return false unless inner_forward == forward
|
65
|
+
inner_day = @day
|
66
|
+
return false unless inner_day == day
|
62
67
|
|
63
|
-
|
64
|
-
return false unless inner_day == day
|
68
|
+
return false unless range.include?(minute: minute)
|
65
69
|
|
66
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
84
|
+
# Range 小余範囲
|
85
|
+
#
|
86
|
+
class Range
|
87
|
+
# @return [Integer] 下限
|
88
|
+
MIN = 0
|
89
|
+
# @return [Integer] 上限
|
90
|
+
MAX = Const::Number::Cycle::DAY
|
91
|
+
# @return [Integer] 遠/近の地点での中間
|
92
|
+
HALF = 7465
|
93
|
+
# @return [Integer] 各地点の最後
|
94
|
+
LAST = 6529
|
95
|
+
|
96
|
+
# @return [Integer] 下限
|
97
|
+
attr_reader :min
|
98
|
+
# @return [Integer] 上限
|
99
|
+
attr_reader :max
|
100
|
+
|
101
|
+
#
|
102
|
+
# 初期化
|
103
|
+
#
|
104
|
+
# @param [Integer] min 下限
|
105
|
+
# @param [Integer] max 上限
|
106
|
+
#
|
107
|
+
def initialize(min: MIN, max: MAX)
|
108
|
+
@min = min
|
109
|
+
@max = max
|
110
|
+
end
|
98
111
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
112
|
+
#
|
113
|
+
# 含まれるか
|
114
|
+
#
|
115
|
+
# @param [Integer] minute 小余
|
116
|
+
#
|
117
|
+
# @return [True] 含まれる
|
118
|
+
# @return [False] 含まれない
|
119
|
+
#
|
120
|
+
def include?(minute:)
|
121
|
+
minute >= min && minute <= max
|
122
|
+
end
|
109
123
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
def include?(minute:)
|
119
|
-
minute >= min && minute <= max
|
124
|
+
#
|
125
|
+
# 分母を返す
|
126
|
+
#
|
127
|
+
# @return [Integer] 分母
|
128
|
+
#
|
129
|
+
def denominator
|
130
|
+
max - min
|
131
|
+
end
|
120
132
|
end
|
121
133
|
|
122
134
|
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
# @return [Integer] 分母
|
135
|
+
# Value 補正値
|
126
136
|
#
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
137
|
+
class Value
|
138
|
+
# @return [Integer] 損益率
|
139
|
+
attr_reader :per
|
140
|
+
# @return [Integer] 眺朒(ちょうじく)積
|
141
|
+
attr_reader :stack
|
131
142
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
# 初期化
|
143
|
-
#
|
144
|
-
# @param [Integer] per 損益率
|
145
|
-
# @param [Integer] stack 眺朒(ちょうじく)積
|
146
|
-
#
|
147
|
-
def initialize(per:, stack:)
|
148
|
-
@per = per
|
149
|
-
@stack = stack
|
150
|
-
end
|
143
|
+
#
|
144
|
+
# 初期化
|
145
|
+
#
|
146
|
+
# @param [Integer] per 損益率
|
147
|
+
# @param [Integer] stack 眺朒(ちょうじく)積
|
148
|
+
#
|
149
|
+
def initialize(per:, stack:)
|
150
|
+
@per = per
|
151
|
+
@stack = stack
|
152
|
+
end
|
151
153
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
154
|
+
#
|
155
|
+
# 文字化
|
156
|
+
#
|
157
|
+
# @return [String] 文字
|
158
|
+
#
|
159
|
+
def to_s
|
160
|
+
"per:#{per}, stack:#{stack}"
|
161
|
+
end
|
159
162
|
end
|
160
|
-
end
|
161
|
-
|
162
|
-
# rubocop:disable Layout/LineLength
|
163
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
|
-
|
164
|
+
# rubocop:disable Layout/LineLength
|
165
|
+
|
166
|
+
#
|
167
|
+
# @return [Array<Row>] 月の補正値情報
|
168
|
+
#
|
169
|
+
LIST = [
|
170
|
+
Row.new(forward: true, day: 1, range: Range.new, value: Value.new(per: +830, stack: 0)),
|
171
|
+
Row.new(forward: true, day: 2, range: Range.new, value: Value.new(per: +726, stack: +830)),
|
172
|
+
Row.new(forward: true, day: 3, range: Range.new, value: Value.new(per: +606, stack: +1556)),
|
173
|
+
Row.new(forward: true, day: 4, range: Range.new, value: Value.new(per: +471, stack: +2162)),
|
174
|
+
Row.new(forward: true, day: 5, range: Range.new, value: Value.new(per: +337, stack: +2633)),
|
175
|
+
Row.new(forward: true, day: 6, range: Range.new, value: Value.new(per: +202, stack: +2970)),
|
176
|
+
Row.new(forward: true, day: 7, range: Range.new(max: Range::HALF), value: Value.new(per: +53, stack: +3172)),
|
177
|
+
Row.new(forward: true, day: 7, range: Range.new(min: Range::HALF), value: Value.new(per: -7, stack: +3225)), # +3172 + 53(初益)
|
178
|
+
Row.new(forward: true, day: 8, range: Range.new, value: Value.new(per: -82, stack: +3218)),
|
179
|
+
Row.new(forward: true, day: 9, range: Range.new, value: Value.new(per: -224, stack: +3136)),
|
180
|
+
Row.new(forward: true, day: 10, range: Range.new, value: Value.new(per: -366, stack: +2912)),
|
181
|
+
Row.new(forward: true, day: 11, range: Range.new, value: Value.new(per: -509, stack: +2546)),
|
182
|
+
Row.new(forward: true, day: 12, range: Range.new, value: Value.new(per: -643, stack: +2037)),
|
183
|
+
Row.new(forward: true, day: 13, range: Range.new, value: Value.new(per: -748, stack: +1394)),
|
184
|
+
Row.new(forward: true, day: 14, range: Range.new(max: Range::LAST), value: Value.new(per: -646, stack: +646)), # 14日の小余は常に6529以下
|
185
|
+
Row.new(forward: false, day: 1, range: Range.new, value: Value.new(per: -830, stack: 0)),
|
186
|
+
Row.new(forward: false, day: 2, range: Range.new, value: Value.new(per: -726, stack: -830)),
|
187
|
+
Row.new(forward: false, day: 3, range: Range.new, value: Value.new(per: -598, stack: -1556)),
|
188
|
+
Row.new(forward: false, day: 4, range: Range.new, value: Value.new(per: -464, stack: -2154)),
|
189
|
+
Row.new(forward: false, day: 5, range: Range.new, value: Value.new(per: -329, stack: -2618)),
|
190
|
+
Row.new(forward: false, day: 6, range: Range.new, value: Value.new(per: -195, stack: -2947)),
|
191
|
+
Row.new(forward: false, day: 7, range: Range.new(max: Range::HALF), value: Value.new(per: -53, stack: -3142)),
|
192
|
+
Row.new(forward: false, day: 7, range: Range.new(min: Range::HALF), value: Value.new(per: +7, stack: -3195)), # -3142 - 53(初益)
|
193
|
+
Row.new(forward: false, day: 8, range: Range.new, value: Value.new(per: +82, stack: -3188)),
|
194
|
+
Row.new(forward: false, day: 9, range: Range.new, value: Value.new(per: +225, stack: -3106)),
|
195
|
+
Row.new(forward: false, day: 10, range: Range.new, value: Value.new(per: +366, stack: -2881)),
|
196
|
+
Row.new(forward: false, day: 11, range: Range.new, value: Value.new(per: +501, stack: -2515)),
|
197
|
+
Row.new(forward: false, day: 12, range: Range.new, value: Value.new(per: +628, stack: -2014)),
|
198
|
+
Row.new(forward: false, day: 13, range: Range.new, value: Value.new(per: +740, stack: -1386)),
|
199
|
+
Row.new(forward: false, day: 14, range: Range.new(max: Range::LAST), value: Value.new(per: +646, stack: -646)) # 14日の小余は常に6529以下
|
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(forward:, day:, minute:)
|
216
|
+
LIST.each do |row|
|
217
|
+
# NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
|
218
|
+
return row if row.match?(forward: forward, day: day, minute: minute)
|
219
|
+
end
|
220
|
+
|
221
|
+
raise ArgumentError.new, "invalid parameter: #{forward}/#{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
|
-
|
226
|
+
#
|
227
|
+
# 小余の下げ幅を求める
|
228
|
+
#
|
229
|
+
# @param [Integer] day 大余
|
230
|
+
# @param [Integer] minute 小余
|
231
|
+
#
|
232
|
+
# @return [Integer] 小余の下げ幅
|
233
|
+
#
|
234
|
+
def minus_minute(day:, minute:)
|
235
|
+
return minute unless HALF_DAYS.include?(day)
|
234
236
|
|
235
|
-
|
237
|
+
return minute unless minute > Range::HALF
|
236
238
|
|
237
|
-
|
239
|
+
minute - Range::HALF
|
240
|
+
end
|
238
241
|
end
|
239
242
|
end
|
240
243
|
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 Senmyou
|
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,75 +9,78 @@ 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
|
-
HALF_ANOMALISTIC_MONTH = Const::Remainder::Lunar::HALF_ANOMALISTIC_MONTH
|
21
|
-
# @return [Cycle::LunarRemainder] 弦
|
22
|
-
QUARTER = Const::Remainder::Lunar::QUARTER
|
23
|
-
|
24
|
-
# @return [True] 進
|
25
|
-
# @return [False] 退
|
26
|
-
attr_reader :forward
|
27
|
-
|
28
|
-
#
|
29
|
-
# 初期化
|
14
|
+
module Senmyou
|
15
|
+
# :nodoc:
|
16
|
+
module Lunar
|
30
17
|
#
|
31
|
-
#
|
32
|
-
# @param [Integer] western_year 西暦年
|
18
|
+
# Location 入暦
|
33
19
|
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
)
|
20
|
+
class Location < Calculation::Lunar::AbstractLocation
|
21
|
+
# @return [Cycle::LunarRemainder] 暦中日(1近点月の半分)
|
22
|
+
HALF_ANOMALISTIC_MONTH = Const::Remainder::Lunar::HALF_ANOMALISTIC_MONTH
|
23
|
+
# @return [Cycle::LunarRemainder] 弦
|
24
|
+
QUARTER = Const::Remainder::Lunar::QUARTER
|
40
25
|
|
41
|
-
# 進
|
42
|
-
@
|
43
|
-
|
26
|
+
# @return [True] 進
|
27
|
+
# @return [False] 退
|
28
|
+
attr_reader :forward
|
44
29
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
30
|
+
#
|
31
|
+
# 初期化
|
32
|
+
#
|
33
|
+
# @param [Cycle::LunarRemainder] lunar_age 天正閏余(大余小余)
|
34
|
+
# @param [Integer] western_year 西暦年
|
35
|
+
#
|
36
|
+
def initialize(lunar_age:, western_year:)
|
37
|
+
super(
|
38
|
+
lunar_age: lunar_age,
|
39
|
+
quarter: QUARTER,
|
40
|
+
western_year: western_year
|
41
|
+
)
|
42
|
+
|
43
|
+
# 進
|
44
|
+
@forward = true
|
52
45
|
end
|
53
46
|
|
54
|
-
|
55
|
-
|
47
|
+
#
|
48
|
+
# 入暦を計算する
|
49
|
+
#
|
50
|
+
def run
|
51
|
+
if calculated
|
52
|
+
decrease(limit: HALF_ANOMALISTIC_MONTH)
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
first
|
57
|
+
end
|
56
58
|
|
57
|
-
|
59
|
+
private
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
#
|
62
|
+
# 初回計算
|
63
|
+
#
|
64
|
+
def first
|
65
|
+
@remainder = Localization.first_remainder(
|
66
|
+
lunar_age: remainder, western_year: western_year
|
67
|
+
)
|
68
|
+
decrease(limit: HALF_ANOMALISTIC_MONTH)
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
+
@calculated = true
|
71
|
+
end
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
#
|
74
|
+
# 大余小余に合わせて減算する(折り返す)
|
75
|
+
#
|
76
|
+
# @param [Cycle::LunarRemainder] limit 上限
|
77
|
+
#
|
78
|
+
def decrease(limit:)
|
79
|
+
return if remainder < limit
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
+
remainder.sub!(limit)
|
82
|
+
@forward = !forward
|
83
|
+
end
|
81
84
|
end
|
82
85
|
end
|
83
86
|
end
|