zakuro 0.9.4 → 1.0.0

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