zakuro 0.9.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) 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 +8 -9
  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/cycle/abstract_solar_term.rb +6 -0
  12. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +2 -2
  13. data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +4 -2
  14. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +1 -1
  15. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +13 -7
  16. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +18 -9
  17. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +6 -2
  18. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +5 -2
  19. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +3 -3
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +12 -4
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +10 -4
  22. data/lib/zakuro/calculation/era/gengou/named_scroll.rb +5 -2
  23. data/lib/zakuro/calculation/era/version/internal/crawler.rb +3 -3
  24. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +1 -1
  25. data/lib/zakuro/calculation/monthly/internal/date_comparer.rb +78 -0
  26. data/lib/zakuro/calculation/monthly/{meta → internal/meta}/all_solar_term.rb +1 -1
  27. data/lib/zakuro/calculation/monthly/{meta → internal/meta}/meta_collector.rb +2 -2
  28. data/lib/zakuro/calculation/monthly/{first_day.rb → internal/part/first_day.rb} +2 -2
  29. data/lib/zakuro/calculation/monthly/{meta.rb → internal/part/meta.rb} +1 -1
  30. data/lib/zakuro/calculation/monthly/internal/solar_term_selector.rb +203 -0
  31. data/lib/zakuro/calculation/monthly/month.rb +38 -74
  32. data/lib/zakuro/calculation/monthly/operated_month.rb +7 -2
  33. data/lib/zakuro/calculation/option/dropped_date/location.rb +8 -1
  34. data/lib/zakuro/calculation/range/dated_full_range.rb +6 -3
  35. data/lib/zakuro/calculation/range/dated_operation_range.rb +2 -1
  36. data/lib/zakuro/calculation/range/medieval_annual_range.rb +0 -2
  37. data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
  38. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +24 -10
  39. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +3 -3
  40. data/lib/zakuro/calculation/summary/internal/option/dropped_date.rb +102 -0
  41. data/lib/zakuro/calculation/summary/internal/option/vanished_date.rb +111 -0
  42. data/lib/zakuro/calculation/summary/internal/option.rb +4 -137
  43. data/lib/zakuro/calculation/summary/japan/range.rb +4 -5
  44. data/lib/zakuro/calculation/summary/western/range.rb +8 -1
  45. data/lib/zakuro/calculation/summary/western/single.rb +10 -5
  46. data/lib/zakuro/context/version_class_resolver.rb +5 -5
  47. data/lib/zakuro/era/japan/calendar.rb +4 -4
  48. data/lib/zakuro/era/japan/gengou/alignment/division.rb +2 -2
  49. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +2 -2
  50. data/lib/zakuro/era/japan/gengou/alignment.rb +35 -6
  51. data/lib/zakuro/era/japan/gengou/resource/parser.rb +17 -16
  52. data/lib/zakuro/era/japan/gengou/resource/validator.rb +3 -394
  53. data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +2 -2
  54. data/lib/zakuro/era/japan/gengou.rb +8 -6
  55. data/lib/zakuro/era/japan/type/base/both/date.rb +51 -0
  56. data/lib/zakuro/era/japan/type/base/both/year.rb +53 -0
  57. data/lib/zakuro/era/japan/type/base/gengou.rb +177 -0
  58. data/lib/zakuro/era/japan/type/base/gengou_set.rb +78 -0
  59. data/lib/zakuro/era/japan/type/base/switch_date.rb +74 -0
  60. data/lib/zakuro/era/japan/type/base/version_range.rb +189 -0
  61. data/lib/zakuro/era/japan/type/validation/both/date.rb +99 -0
  62. data/lib/zakuro/era/japan/type/validation/both/year.rb +75 -0
  63. data/lib/zakuro/era/japan/type/validation/gengou.rb +93 -0
  64. data/lib/zakuro/era/japan/type/validation/gengou_set.rb +133 -0
  65. data/lib/zakuro/era/japan/type/validation/switch_date.rb +73 -0
  66. data/lib/zakuro/era/japan/type/validation/version_range.rb +109 -0
  67. data/lib/zakuro/era/japan/type/validation/version_root.rb +102 -0
  68. data/lib/zakuro/era/japan/version/resource/parser.rb +266 -0
  69. data/lib/zakuro/era/japan/version/resource/validator.rb +37 -0
  70. data/lib/zakuro/era/japan/version/resource/yaml/version.yaml +80 -0
  71. data/lib/zakuro/era/japan/version/resource.rb +22 -0
  72. data/lib/zakuro/era/japan/version.rb +4 -115
  73. data/lib/zakuro/era/western/calendar.rb +2 -2
  74. data/lib/zakuro/exception/zakuro_error.rb +1 -1
  75. data/lib/zakuro/merchant.rb +5 -5
  76. data/lib/zakuro/operation/month/parser.rb +2 -2
  77. data/lib/zakuro/operation/yaml/month.yaml +8 -40
  78. data/lib/zakuro/output/logger.rb +4 -4
  79. data/lib/zakuro/parameter/catalog/basis_date.rb +55 -0
  80. data/lib/zakuro/parameter/catalog/column.rb +57 -0
  81. data/lib/zakuro/parameter/catalog/option.rb +60 -0
  82. data/lib/zakuro/parameter/catalog/range.rb +81 -0
  83. data/lib/zakuro/parameter/condition.rb +108 -0
  84. data/lib/zakuro/result/core.rb +2 -2
  85. data/lib/zakuro/{tools → tool}/remainder_comparer.rb +3 -2
  86. data/lib/zakuro/{tools → tool}/stringifier.rb +3 -3
  87. data/lib/zakuro/{tools → tool}/typeconv.rb +2 -2
  88. data/lib/zakuro/{tools → tool}/typeof.rb +2 -2
  89. data/lib/zakuro/version/daien/const/number.rb +42 -39
  90. data/lib/zakuro/version/daien/const/remainder.rb +38 -35
  91. data/lib/zakuro/version/daien/cycle/remainder.rb +77 -74
  92. data/lib/zakuro/version/daien/cycle/solar_term.rb +18 -15
  93. data/lib/zakuro/version/daien/daien.rb +8 -5
  94. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +67 -64
  95. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +15 -12
  96. data/lib/zakuro/version/daien/option/vanished_date/parameter.rb +15 -12
  97. data/lib/zakuro/version/daien/range/annual_range.rb +27 -24
  98. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +209 -206
  99. data/lib/zakuro/version/daien/stella/lunar/localization.rb +32 -29
  100. data/lib/zakuro/version/daien/stella/lunar/location.rb +53 -50
  101. data/lib/zakuro/version/daien/stella/lunar/value.rb +65 -62
  102. data/lib/zakuro/version/daien/stella/origin/average_november.rb +23 -20
  103. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +42 -39
  104. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +44 -41
  105. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +74 -71
  106. data/lib/zakuro/version/daien/stella/solar/average.rb +68 -65
  107. data/lib/zakuro/version/daien/stella/solar/interval.rb +95 -92
  108. data/lib/zakuro/version/daien/stella/solar/location.rb +41 -38
  109. data/lib/zakuro/version/daien/stella/solar/value.rb +21 -18
  110. data/lib/zakuro/version/genka/const/number.rb +31 -28
  111. data/lib/zakuro/version/genka/const/remainder.rb +20 -17
  112. data/lib/zakuro/version/genka/cycle/remainder.rb +72 -69
  113. data/lib/zakuro/version/genka/cycle/solar_term.rb +18 -15
  114. data/lib/zakuro/version/genka/genka.rb +8 -5
  115. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +82 -79
  116. data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +13 -10
  117. data/lib/zakuro/version/genka/option/vanished_date/parameter.rb +13 -10
  118. data/lib/zakuro/version/genka/range/annual_range.rb +57 -54
  119. data/lib/zakuro/version/genka/stella/origin/first_term.rb +44 -41
  120. data/lib/zakuro/version/genka/stella/origin/january.rb +38 -35
  121. data/lib/zakuro/version/genka/stella/solar/average.rb +24 -21
  122. data/lib/zakuro/version/gihou/const/number.rb +40 -37
  123. data/lib/zakuro/version/gihou/const/remainder.rb +32 -29
  124. data/lib/zakuro/version/gihou/cycle/remainder.rb +38 -35
  125. data/lib/zakuro/version/gihou/cycle/solar_term.rb +18 -15
  126. data/lib/zakuro/version/gihou/gihou.rb +8 -5
  127. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +68 -65
  128. data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +13 -10
  129. data/lib/zakuro/version/gihou/option/vanished_date/parameter.rb +13 -10
  130. data/lib/zakuro/version/gihou/range/annual_range.rb +27 -24
  131. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +212 -209
  132. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +32 -29
  133. data/lib/zakuro/version/gihou/stella/lunar/location.rb +53 -50
  134. data/lib/zakuro/version/gihou/stella/lunar/value.rb +65 -62
  135. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +23 -20
  136. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +42 -39
  137. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +44 -41
  138. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +74 -71
  139. data/lib/zakuro/version/gihou/stella/solar/average.rb +67 -64
  140. data/lib/zakuro/version/gihou/stella/solar/interval.rb +95 -92
  141. data/lib/zakuro/version/gihou/stella/solar/location.rb +41 -38
  142. data/lib/zakuro/version/gihou/stella/solar/value.rb +21 -18
  143. data/lib/zakuro/version/gregorio/gregorio.rb +8 -5
  144. data/lib/zakuro/version/houryaku/houryaku.rb +8 -5
  145. data/lib/zakuro/version/joukyou/joukyou.rb +8 -5
  146. data/lib/zakuro/version/kansei/kansei.rb +8 -5
  147. data/lib/zakuro/version/senmyou/const/number.rb +40 -37
  148. data/lib/zakuro/version/senmyou/const/remainder.rb +35 -32
  149. data/lib/zakuro/version/senmyou/cycle/remainder.rb +74 -71
  150. data/lib/zakuro/version/senmyou/cycle/solar_term.rb +18 -15
  151. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +69 -66
  152. data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +15 -12
  153. data/lib/zakuro/version/senmyou/option/vanished_date/parameter.rb +15 -12
  154. data/lib/zakuro/version/senmyou/range/annual_range.rb +27 -24
  155. data/lib/zakuro/version/senmyou/senmyou.rb +8 -5
  156. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +206 -203
  157. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +32 -29
  158. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +60 -57
  159. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +66 -63
  160. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +23 -20
  161. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +42 -39
  162. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +44 -41
  163. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +74 -71
  164. data/lib/zakuro/version/senmyou/stella/solar/average.rb +67 -64
  165. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +93 -90
  166. data/lib/zakuro/version/senmyou/stella/solar/location.rb +41 -38
  167. data/lib/zakuro/version/senmyou/stella/solar/value.rb +23 -20
  168. data/lib/zakuro/version/tenpou/tenpou.rb +8 -5
  169. metadata +40 -15
  170. data/lib/zakuro/condition.rb +0 -306
  171. data/lib/zakuro/era/japan/gengou/resource/type.rb +0 -356
  172. /data/lib/zakuro/calculation/monthly/{operated_solar_term.rb → internal/operated_solar_term.rb} +0 -0
  173. /data/lib/zakuro/calculation/monthly/{const.rb → internal/part/const.rb} +0 -0
  174. /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 Senmyou
8
+ module Version
9
9
  # :nodoc:
10
- module Lunar
11
- #
12
- # Adjustment 補正値情報
13
- #
14
- module Adjustment
15
- # @return [Integer] 遠/近の地点での中間
16
- HALF_DAYS = [7].freeze
17
-
10
+ module Senmyou
11
+ # :nodoc:
12
+ module Lunar
18
13
  #
19
- # Row 行情報
14
+ # Adjustment 補正値情報
20
15
  #
21
- class Row
22
- # @return [True] 進(遠地点より数える)
23
- # @return [False] 退(近地点より数える)
24
- attr_reader :forward
25
- # @return [Integer] 入暦(1-14)
26
- attr_reader :day
27
- # @return [Range] 小余範囲
28
- attr_reader :range
29
- # @return [Value] 補正値
30
- attr_reader :value
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
- # :reek:ControlParameter
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
- inner_day = @day
64
- return false unless inner_day == day
68
+ return false unless range.include?(minute: minute)
65
69
 
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
89
- # @return [Integer] 遠/近の地点での中間
90
- HALF = 7465
91
- # @return [Integer] 各地点の最後
92
- LAST = 6529
93
-
94
- # @return [Integer] 下限
95
- attr_reader :min
96
- # @return [Integer] 上限
97
- attr_reader :max
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
- # @param [Integer] min 下限
103
- # @param [Integer] max 上限
104
- #
105
- def initialize(min: MIN, max: MAX)
106
- @min = min
107
- @max = max
108
- end
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
- # @param [Integer] minute 小余
114
- #
115
- # @return [True] 含まれる
116
- # @return [False] 含まれない
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
- def denominator
128
- max - min
129
- end
130
- end
137
+ class Value
138
+ # @return [Integer] 損益率
139
+ attr_reader :per
140
+ # @return [Integer] 眺朒(ちょうじく)積
141
+ attr_reader :stack
131
142
 
132
- #
133
- # Value 補正値
134
- #
135
- class Value
136
- # @return [Integer] 損益率
137
- attr_reader :per
138
- # @return [Integer] 眺朒(ちょうじく)積
139
- attr_reader :stack
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
- # @return [String] 文字
156
- #
157
- def to_s
158
- "per:#{per}, stack:#{stack}"
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
- # @return [Array<Row>] 月の補正値情報
166
- #
167
- LIST = [
168
- Row.new(forward: true, day: 1, range: Range.new, value: Value.new(per: +830, stack: 0)),
169
- Row.new(forward: true, day: 2, range: Range.new, value: Value.new(per: +726, stack: +830)),
170
- Row.new(forward: true, day: 3, range: Range.new, value: Value.new(per: +606, stack: +1556)),
171
- Row.new(forward: true, day: 4, range: Range.new, value: Value.new(per: +471, stack: +2162)),
172
- Row.new(forward: true, day: 5, range: Range.new, value: Value.new(per: +337, stack: +2633)),
173
- Row.new(forward: true, day: 6, range: Range.new, value: Value.new(per: +202, stack: +2970)),
174
- Row.new(forward: true, day: 7, range: Range.new(max: Range::HALF), value: Value.new(per: +53, stack: +3172)),
175
- Row.new(forward: true, day: 7, range: Range.new(min: Range::HALF), value: Value.new(per: -7, stack: +3225)), # +3172 + 53(初益)
176
- Row.new(forward: true, day: 8, range: Range.new, value: Value.new(per: -82, stack: +3218)),
177
- Row.new(forward: true, day: 9, range: Range.new, value: Value.new(per: -224, stack: +3136)),
178
- Row.new(forward: true, day: 10, range: Range.new, value: Value.new(per: -366, stack: +2912)),
179
- Row.new(forward: true, day: 11, range: Range.new, value: Value.new(per: -509, stack: +2546)),
180
- Row.new(forward: true, day: 12, range: Range.new, value: Value.new(per: -643, stack: +2037)),
181
- Row.new(forward: true, day: 13, range: Range.new, value: Value.new(per: -748, stack: +1394)),
182
- Row.new(forward: true, day: 14, range: Range.new(max: Range::LAST), value: Value.new(per: -646, stack: +646)), # 14日の小余は常に6529以下
183
- Row.new(forward: false, day: 1, range: Range.new, value: Value.new(per: -830, stack: 0)),
184
- Row.new(forward: false, day: 2, range: Range.new, value: Value.new(per: -726, stack: -830)),
185
- Row.new(forward: false, day: 3, range: Range.new, value: Value.new(per: -598, stack: -1556)),
186
- Row.new(forward: false, day: 4, range: Range.new, value: Value.new(per: -464, stack: -2154)),
187
- Row.new(forward: false, day: 5, range: Range.new, value: Value.new(per: -329, stack: -2618)),
188
- Row.new(forward: false, day: 6, range: Range.new, value: Value.new(per: -195, stack: -2947)),
189
- Row.new(forward: false, day: 7, range: Range.new(max: Range::HALF), value: Value.new(per: -53, stack: -3142)),
190
- Row.new(forward: false, day: 7, range: Range.new(min: Range::HALF), value: Value.new(per: +7, stack: -3195)), # -3142 - 53(初益)
191
- Row.new(forward: false, day: 8, range: Range.new, value: Value.new(per: +82, stack: -3188)),
192
- Row.new(forward: false, day: 9, range: Range.new, value: Value.new(per: +225, stack: -3106)),
193
- Row.new(forward: false, day: 10, range: Range.new, value: Value.new(per: +366, stack: -2881)),
194
- Row.new(forward: false, day: 11, range: Range.new, value: Value.new(per: +501, stack: -2515)),
195
- Row.new(forward: false, day: 12, range: Range.new, value: Value.new(per: +628, stack: -2014)),
196
- Row.new(forward: false, day: 13, range: Range.new, value: Value.new(per: +740, stack: -1386)),
197
- Row.new(forward: false, day: 14, range: Range.new(max: Range::LAST), value: Value.new(per: +646, stack: -646)) # 14日の小余は常に6529以下
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(forward:, day:, minute:)
214
- LIST.each do |row|
215
- # NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
216
- return row if row.match?(forward: forward, day: day, minute: minute)
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
- raise ArgumentError.new, "invalid parameter: #{forward}/#{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
- return minute unless HALF_DAYS.include?(day)
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
- return minute unless minute > Range::HALF
237
+ return minute unless minute > Range::HALF
236
238
 
237
- minute - Range::HALF
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 Senmyou
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 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
- 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,75 +9,78 @@ require_relative './localization'
9
9
  # :nodoc:
10
10
  module Zakuro
11
11
  # :nodoc:
12
- module Senmyou
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
- 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
- # @param [Cycle::LunarRemainder] lunar_age 天正閏余(大余小余)
32
- # @param [Integer] western_year 西暦年
18
+ # Location 入暦
33
19
  #
34
- def initialize(lunar_age:, western_year:)
35
- super(
36
- lunar_age: lunar_age,
37
- quarter: QUARTER,
38
- western_year: western_year
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
- @forward = true
43
- end
26
+ # @return [True]
27
+ # @return [False] 退
28
+ attr_reader :forward
44
29
 
45
- #
46
- # 入暦を計算する
47
- #
48
- def run
49
- if calculated
50
- decrease(limit: HALF_ANOMALISTIC_MONTH)
51
- return
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
- first
55
- end
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
- private
59
+ private
58
60
 
59
- #
60
- # 初回計算
61
- #
62
- def first
63
- @remainder = Localization.first_remainder(
64
- lunar_age: remainder, western_year: western_year
65
- )
66
- decrease(limit: HALF_ANOMALISTIC_MONTH)
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
- @calculated = true
69
- end
70
+ @calculated = true
71
+ end
70
72
 
71
- #
72
- # 大余小余に合わせて減算する(折り返す)
73
- #
74
- # @param [Cycle::LunarRemainder] limit 上限
75
- #
76
- def decrease(limit:)
77
- return if remainder < limit
73
+ #
74
+ # 大余小余に合わせて減算する(折り返す)
75
+ #
76
+ # @param [Cycle::LunarRemainder] limit 上限
77
+ #
78
+ def decrease(limit:)
79
+ return if remainder < limit
78
80
 
79
- remainder.sub!(limit)
80
- @forward = !forward
81
+ remainder.sub!(limit)
82
+ @forward = !forward
83
+ end
81
84
  end
82
85
  end
83
86
  end