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,238 +5,241 @@ require_relative '../../const/number'
5
5
  # :nodoc:
6
6
  module Zakuro
7
7
  # :nodoc:
8
- module Daien
8
+ module Version
9
9
  # :nodoc:
10
- module Lunar
11
- #
12
- # Adjustment 補正値情報
13
- #
14
- module Adjustment
15
- # 『歴代天文律暦等志彙編 七』中華書房 p.2230
10
+ module Daien
11
+ # :nodoc:
12
+ module Lunar
16
13
  #
17
- # 遠/近の地点での中間
14
+ # Adjustment 補正値情報
18
15
  #
19
- # @return [Hash<Integer>] 遠/近の地点での中間
20
- DAY_LIMIT = {
21
- 7 => 2701,
22
- 14 => 2363,
23
- 21 => 2024,
24
- 28 => 1686
25
- }.freeze
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
- # @param [Integer] day 入暦(1-14)
42
- # @param [Range] range 小余範囲
43
- # @param [Value] value 補正値
44
- #
45
- def initialize(day:, range:, value:)
46
- @day = day
47
- @range = range
48
- @value = value
49
- end
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
- # :reek:ControlParameter
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
- true
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
- # @return [Integer] 分母
75
- #
76
- def denominator
77
- range.denominator
78
- end
79
- end
80
-
81
- #
82
- # Range 小余範囲
83
- #
84
- class Range
85
- # @return [Integer] 下限
86
- MIN = 0
87
- # @return [Integer] 上限
88
- MAX = Const::Number::Cycle::DAY
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
- # @return [Integer] 下限
91
- attr_reader :min
92
- # @return [Integer] 上限
93
- attr_reader :max
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
- # @param [Integer] min 下限
99
- # @param [Integer] max 上限
100
- #
101
- def initialize(min: MIN, max: MAX)
102
- @min = min
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
- def include?(minute:)
115
- minute >= min && minute <= max
116
- end
133
+ class Value
134
+ # @return [Integer] 増減率
135
+ attr_reader :per
136
+ # @return [Integer] 遅速積
137
+ attr_reader :stack
117
138
 
118
- #
119
- # 分母を返す
120
- #
121
- # @return [Integer] 分母
122
- #
123
- def denominator
124
- max - min
125
- end
126
- end
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
- # @return [String] 文字
152
- #
153
- def to_s
154
- "per:#{per}, stack:#{stack}"
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
- # rubocop:disable Layout/LineLength
159
-
160
- # 『歴代天文律暦等志彙編 七』中華書房 p.2228-2230
161
- #
162
- # @note 7日、14日、21日、28日の小余は DAY_LIMIT を参照のこと
163
- #
164
- # @return [Array<Row>] 月の補正値情報
165
- #
166
- LIST = [
167
- Row.new(day: 1, range: Range.new, value: Value.new(per: +297, stack: 0)),
168
- Row.new(day: 2, range: Range.new, value: Value.new(per: +259, stack: +297)),
169
- Row.new(day: 3, range: Range.new, value: Value.new(per: +220, stack: +556)),
170
- Row.new(day: 4, range: Range.new, value: Value.new(per: +180, stack: +776)),
171
- Row.new(day: 5, range: Range.new, value: Value.new(per: +139, stack: +956)),
172
- Row.new(day: 6, range: Range.new, value: Value.new(per: +97, stack: +1095)),
173
- Row.new(day: 7, range: Range.new(max: DAY_LIMIT[7]), value: Value.new(per: +48, stack: +1192)),
174
- Row.new(day: 7, range: Range.new(min: DAY_LIMIT[7]), value: Value.new(per: -6, stack: +1240)), # stack: +1192 + 48
175
- Row.new(day: 8, range: Range.new, value: Value.new(per: -64, stack: +1234)),
176
- Row.new(day: 9, range: Range.new, value: Value.new(per: -106, stack: +1170)),
177
- Row.new(day: 10, range: Range.new, value: Value.new(per: -148, stack: +1064)),
178
- Row.new(day: 11, range: Range.new, value: Value.new(per: -189, stack: +916)),
179
- Row.new(day: 12, range: Range.new, value: Value.new(per: -229, stack: +727)),
180
- Row.new(day: 13, range: Range.new, value: Value.new(per: -267, stack: +498)),
181
- Row.new(day: 14, range: Range.new(max: DAY_LIMIT[14]), value: Value.new(per: -231, stack: +231)),
182
- Row.new(day: 14, range: Range.new(min: DAY_LIMIT[14]), value: Value.new(per: -66, stack: 0)), # stack: +232 - 231
183
- Row.new(day: 15, range: Range.new, value: Value.new(per: -289, stack: -66)),
184
- Row.new(day: 16, range: Range.new, value: Value.new(per: -250, stack: -355)),
185
- Row.new(day: 17, range: Range.new, value: Value.new(per: -211, stack: -605)),
186
- Row.new(day: 18, range: Range.new, value: Value.new(per: -171, stack: -816)),
187
- Row.new(day: 19, range: Range.new, value: Value.new(per: -130, stack: -987)),
188
- Row.new(day: 20, range: Range.new, value: Value.new(per: -87, stack: -1117)),
189
- Row.new(day: 21, range: Range.new(max: DAY_LIMIT[21]), value: Value.new(per: -36, stack: -1204)),
190
- Row.new(day: 21, range: Range.new(min: DAY_LIMIT[21]), value: Value.new(per: +18, stack: -1240)), # stack: -1204 - 36
191
- Row.new(day: 22, range: Range.new, value: Value.new(per: +73, stack: -1222)),
192
- Row.new(day: 23, range: Range.new, value: Value.new(per: +116, stack: -1149)),
193
- Row.new(day: 24, range: Range.new, value: Value.new(per: +157, stack: -1033)),
194
- Row.new(day: 25, range: Range.new, value: Value.new(per: +198, stack: -876)),
195
- Row.new(day: 26, range: Range.new, value: Value.new(per: +237, stack: -678)),
196
- Row.new(day: 27, range: Range.new, value: Value.new(per: +276, stack: -441)),
197
- Row.new(day: 28, range: Range.new(max: DAY_LIMIT[28]), value: Value.new(per: +165, stack: -165))
198
- ].freeze
199
- # rubocop:enable Layout/LineLength
200
-
201
- class << self
202
- #
203
- # 月軌道の補正に必要な基本値を引き当てる
204
- #
205
- # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
206
- # @param [Integer] day 大余
207
- # @param [Integer] minute 小余
208
- #
209
- # @return [Row] 補正値
210
- #
211
- # @raise [ArgumentError] 引数エラー
212
- #
213
- def specify(day:, minute:)
214
- LIST.each do |row|
215
- # NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
216
- return row if row.match?(day: day, minute: minute)
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
- raise ArgumentError.new, "invalid parameter: #{day}/#{minute}"
220
- end
221
-
222
- # :reek:ControlParameter
224
+ # :reek:ControlParameter
223
225
 
224
- #
225
- # 小余の下げ幅を求める
226
- #
227
- # @param [Integer] day 大余
228
- # @param [Integer] minute 小余
229
- #
230
- # @return [Integer] 小余の下げ幅
231
- #
232
- def minus_minute(day:, minute:)
233
- limit = DAY_LIMIT.fetch(day, -1)
234
- # 該当なし
235
- return minute if limit == -1
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
- return minute unless minute > limit
239
+ return minute unless minute > limit
238
240
 
239
- minute - limit
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 Daien
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 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
- 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 Daien
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 Daien
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