zakuro 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +30 -12
  3. data/doc/operation/csv/month.csv +202 -202
  4. data/doc/operation/operation.xlsx +0 -0
  5. data/doc/operation/transfer.rb +6 -2
  6. data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
  7. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
  8. data/lib/zakuro/calculation/base/year.rb +107 -0
  9. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +471 -0
  10. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
  11. data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
  12. data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
  13. data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
  14. data/lib/zakuro/calculation/monthly/month.rb +187 -0
  15. data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
  16. data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
  17. data/lib/zakuro/calculation/range/full_range.rb +210 -0
  18. data/lib/zakuro/calculation/range/operated_range.rb +144 -0
  19. data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
  20. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
  21. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
  22. data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
  23. data/lib/zakuro/calculation/summary/single.rb +129 -0
  24. data/lib/zakuro/condition.rb +16 -13
  25. data/lib/zakuro/era/japan/gengou/parser.rb +1 -3
  26. data/lib/zakuro/era/japan/gengou/type.rb +3 -3
  27. data/lib/zakuro/era/japan/gengou/validator.rb +15 -13
  28. data/lib/zakuro/merchant.rb +2 -2
  29. data/lib/zakuro/operation/month/parser.rb +132 -36
  30. data/lib/zakuro/operation/month/type.rb +11 -10
  31. data/lib/zakuro/operation/month/validator.rb +332 -28
  32. data/lib/zakuro/operation/operation.rb +21 -0
  33. data/lib/zakuro/operation/yaml/month.yaml +1 -1
  34. data/lib/zakuro/output/error.rb +7 -6
  35. data/lib/zakuro/output/logger.rb +50 -49
  36. data/lib/zakuro/output/response.rb +145 -144
  37. data/lib/zakuro/result/operation.rb +64 -36
  38. data/lib/zakuro/tools/stringifier.rb +2 -2
  39. data/lib/zakuro/tools/typeof.rb +2 -2
  40. data/lib/zakuro/version.rb +1 -1
  41. data/lib/zakuro/version/abstract_version.rb +1 -1
  42. data/lib/zakuro/version/context.rb +23 -0
  43. data/lib/zakuro/version/senmyou/const/number.rb +51 -0
  44. data/lib/zakuro/version/senmyou/const/remainder.rb +43 -0
  45. data/lib/zakuro/version/senmyou/cycle/remainder.rb +61 -0
  46. data/lib/zakuro/version/senmyou/cycle/solar_term.rb +31 -0
  47. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +166 -181
  48. data/lib/zakuro/version/senmyou/range/annual_range.rb +86 -159
  49. data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
  50. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
  51. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +45 -0
  52. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +108 -0
  53. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +89 -0
  54. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
  55. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
  56. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
  57. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
  58. data/lib/zakuro/version/senmyou/stella/solar/average.rb +175 -0
  59. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
  60. data/lib/zakuro/version/senmyou/stella/solar/location.rb +164 -0
  61. data/lib/zakuro/version/senmyou/stella/solar/value.rb +138 -0
  62. data/lib/zakuro/version/version_class_resolver.rb +62 -0
  63. data/lib/zakuro/version_factory.rb +2 -2
  64. metadata +38 -24
  65. data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
  66. data/lib/zakuro/cycle/zodiac.rb +0 -103
  67. data/lib/zakuro/version/senmyou/base/era.rb +0 -83
  68. data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
  69. data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
  70. data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
  71. data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -76
  72. data/lib/zakuro/version/senmyou/base/year.rb +0 -104
  73. data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
  74. data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -48
  75. data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
  76. data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
  77. data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -167
  78. data/lib/zakuro/version/senmyou/range/full_range.rb +0 -324
  79. data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -105
  80. data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -163
  81. data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -99
  82. data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
  83. data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -214
  84. data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -394
  85. data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
  86. data/lib/zakuro/version/senmyou/summary/single.rb +0 -71
@@ -1,184 +1,111 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../../../output/logger'
4
- require_relative '../base/remainder'
5
- require_relative '../monthly/initialized_month'
6
- require_relative '../base/solar_term'
4
+ require_relative '../cycle/remainder'
5
+ require_relative '../cycle/solar_term'
6
+ require_relative '../../../calculation/monthly/initialized_month'
7
7
  require_relative '../monthly/lunar_phase'
8
- require_relative '../stella/solar_orbit'
9
- require_relative '../stella/solar_average'
10
- require_relative '../stella/lunar_orbit'
8
+ require_relative '../stella/lunar/location'
9
+ require_relative '../stella/lunar/value'
10
+ require_relative '../stella/solar/average'
11
+ require_relative '../stella/solar/location'
12
+ require_relative '../stella/solar/value'
13
+ require_relative '../stella/origin/lunar_age'
14
+ require_relative '../stella/origin/average_november'
11
15
 
12
16
  # :nodoc:
13
17
  module Zakuro
14
18
  # :nodoc:
15
19
  module Senmyou
16
- #
17
- # AnnualRange 年間範囲
18
- #
19
- module AnnualRange
20
- # @return [Logger] ロガー
21
- LOGGER = Logger.new(location: 'annual_range')
22
-
23
- # :reek:TooManyStatements { max_statements: 6 }
24
-
25
- #
26
- # 11月定朔(冬至が含まれる月の1日:補正済)を求める
27
- #
28
- # @param [Integer] western_year 西暦年
29
- #
30
- # @return [Remainder] 11月定朔
31
- #
32
- def self.calc_last_november_1st(western_year:)
33
- # 天正閏余
34
- winter_solstice_age = \
35
- WinterSolstice.calc_moon_age(western_year: western_year)
36
- # 11月経朔
37
- november_1st = \
38
- WinterSolstice.calc_averaged_last_november_1st(western_year: western_year)
39
- # 11月定朔
40
-
41
- # 補正
42
- correction_value = correction_value_on_last_november_1st(
43
- winter_solstice_age: winter_solstice_age,
44
- western_year: western_year
45
- )
46
-
47
- result = november_1st.add(Remainder.new(day: 0, minute: correction_value,
48
- second: 0))
49
- # 進朔
50
- result.up_on_new_moon!
51
- result
52
- end
53
-
54
- # :reek:TooManyStatements { max_statements: 6 }
55
-
56
- #
57
- # 一覧取得する
20
+ # :nodoc:
21
+ module Range
58
22
  #
59
- # * 対象年に対して、前年11月-当年11月までを出力する
60
- # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
23
+ # AnnualRange 年間範囲
61
24
  #
62
- # @param [Integer] western_year 西暦年
63
- #
64
- # @return [Array<Month>] 1年データ
65
- #
66
- def self.collect_annual_range_after_last_november_1st(western_year:)
67
- annual_range = initialized_annual_range(western_year: western_year)
68
-
69
- apply_big_and_small_of_the_month(annual_range: annual_range)
25
+ module AnnualRange
26
+ # @return [Output::Logger] ロガー
27
+ LOGGER = Output::Logger.new(location: 'annual_range')
70
28
 
71
- SolarAverage.set_solar_terms_into_annual_range(western_year: western_year,
72
- annual_range: annual_range)
29
+ # :reek:TooManyStatements { max_statements: 6 }
73
30
 
74
- # 月間隔を取得するためだけの末尾要素を削除
75
- annual_range.pop
76
-
77
- adjust_leap_month(annual_range: annual_range)
78
-
79
- annual_range
80
- end
31
+ #
32
+ # 一覧取得する
33
+ #
34
+ # * 対象年に対して、前年11月-当年11月までを出力する
35
+ # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
36
+ #
37
+ # @param [Context] context 暦コンテキスト
38
+ # @param [Integer] western_year 西暦年
39
+ #
40
+ # @return [Array<Month>] 1年データ
41
+ #
42
+ def self.get(context:, western_year:)
43
+ annual_range = initialized_annual_range(context: context, western_year: western_year)
81
44
 
82
- #
83
- # 11月定朔の補正値を求める
84
- #
85
- # @param [Remainder] winter_solstice_age 天正閏余
86
- # @param [Integer] western_year 西暦年
87
- #
88
- # @return [Integer] 補正値
89
- #
90
- def self.correction_value_on_last_november_1st(winter_solstice_age:, western_year:)
91
- # 補正
92
- solar_term = SolarTerm.new(
93
- remainder: winter_solstice_age
94
- )
95
- solar_term = \
96
- SolarOrbit.calc_solar_term_by_remainder(
97
- solar_term: solar_term
98
- )
45
+ apply_big_and_small_of_the_month(annual_range: annual_range)
99
46
 
100
- moon_remainder, is_forward = LunarOrbit.calc_moon_point(
101
- remainder: winter_solstice_age, western_year: western_year
102
- )
47
+ solar_average = Solar::Average.new(western_year: western_year)
48
+ solar_average.set(annual_range: annual_range)
103
49
 
104
- SolarOrbit.calc_sun_orbit_value(solar_term: solar_term) +
105
- LunarOrbit.calc_moon_orbit_value(remainder_month: moon_remainder,
106
- is_forward: is_forward)
107
- end
108
- private_class_method :correction_value_on_last_november_1st
50
+ # 月間隔を取得するためだけの末尾要素を削除
51
+ annual_range.pop
109
52
 
110
- #
111
- # 1年データを取得する
112
- #
113
- # @param [Integer] western_year 西暦年
114
- #
115
- # @return [Array<Month>] 1年データ
116
- #
117
- def self.initialized_annual_range(western_year:)
118
- result = []
119
- lunar_phase = LunarPhase.new(western_year: western_year)
120
-
121
- is_last_year = true
122
-
123
- monthes = [11, 12] + [*1..12]
124
-
125
- monthes.each do |month|
126
- LOGGER.debug('---', "month: #{month}", "is_last_year: #{is_last_year}")
127
-
128
- adjusted = lunar_phase.next_month
129
-
130
- result.push(
131
- InitializedMonth.new(month_label: MonthLabel.new(number: month),
132
- first_day: FirstDay.new(remainder: adjusted),
133
- is_last_year: is_last_year, phase_index: 0)
134
- )
135
- is_last_year = false if month == 12
53
+ initialize_month_label(annual_range: annual_range)
136
54
  end
137
- result
138
- end
139
- private_class_method :initialized_annual_range
140
55
 
141
- #
142
- # 1年データの各月に月の大小を設定する
143
- #
144
- # @param [Array<Month>] annual_range 1年データ
145
- #
146
- def self.apply_big_and_small_of_the_month(annual_range:)
147
- annual_range.each_with_index do |range, index|
148
- # 最後は比較対象がないためスキップする(=計算外の余分な月が最後に必要である)
149
- next if index == annual_range.size - 1
150
-
151
- next_month = annual_range[index + 1]
152
- range.eval_many_days(next_month_day: next_month.remainder.day)
56
+ #
57
+ # 1年データを取得する
58
+ #
59
+ # @param [Context] context 暦コンテキスト
60
+ # @param [Integer] western_year 西暦年
61
+ #
62
+ # @return [Array<Month>] 1年データ
63
+ #
64
+ def self.initialized_annual_range(context:, western_year:)
65
+ result = []
66
+ lunar_phase = Monthly::LunarPhase.new(western_year: western_year)
67
+
68
+ # 14ヶ月分を生成する(閏年で最大13ヶ月 + 末月の大小/二十四節気を求めるために必要な月)
69
+ (0..13).each do |_index|
70
+ adjusted = lunar_phase.next_month
71
+
72
+ result.push(
73
+ Calculation::Monthly::InitializedMonth.new(
74
+ context: context,
75
+ month_label: Calculation::Monthly::MonthLabel.new,
76
+ first_day: Calculation::Monthly::FirstDay.new(remainder: adjusted),
77
+ phase_index: 0
78
+ )
79
+ )
80
+ end
81
+
82
+ result
153
83
  end
154
- end
155
- private_class_method :apply_big_and_small_of_the_month
156
-
157
- # :reek:TooManyStatements { max_statements: 10 }
158
-
159
- #
160
- # 閏月が存在した場合に以降の月を1つずつ減らす
161
- # @example 7,8,9 と続く月の8月が閏の場合、7, 閏7, 8 となる
162
- #
163
- # @param [Array<Month>] annual_range 1年データ
164
- #
165
- def self.adjust_leap_month(annual_range:)
166
- # 閏による月の再調整を行う
167
- leaped = false
168
- annual_range.each_with_index do |month, index|
169
- month.eval_leaped
170
- # NOTE: 初回閏月(閏11月)は前回月が存在しないため調整外
171
- leaped = true if month.leaped? && !index.zero?
172
-
173
- next unless leaped
174
-
175
- # NOTE: 常気法では閏月は2-3年に一度のため、1年に二度発生しない前提
176
-
177
- # 閏の分だけ1ヶ月ずらす
178
- month.back_to_last_month
84
+ private_class_method :initialized_annual_range
85
+
86
+ #
87
+ # 1年データの各月に月の大小を設定する
88
+ #
89
+ # @param [Array<Month>] annual_range 1年データ
90
+ #
91
+ def self.apply_big_and_small_of_the_month(annual_range:)
92
+ # NOTE: 最後の月は処理できない(=計算外の余分な月が最後に必要である)
93
+ annual_range.each_cons(2) do |(current_month, next_month)|
94
+ current_month.eval_many_days(next_month_day: next_month.remainder.day)
95
+ end
96
+ end
97
+ private_class_method :apply_big_and_small_of_the_month
98
+
99
+ #
100
+ # 月表示情報を更新する
101
+ #
102
+ # @param [Array<Month>] annual_range 1年データ
103
+ #
104
+ def self.initialize_month_label(annual_range:)
105
+ annual_range.each(&:rename_month_label_by_solar_term)
179
106
  end
107
+ private_class_method :initialize_month_label
180
108
  end
181
- private_class_method :adjust_leap_month
182
109
  end
183
110
  end
184
111
  end
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'date'
4
- require_relative '../abstract_version'
5
4
  require_relative '../../era/western'
6
- require_relative 'summary/single'
5
+ require_relative '../abstract_version'
6
+ require_relative '../context'
7
+ require_relative '../../calculation/summary/single'
7
8
 
8
9
  # :nodoc:
9
10
  module Zakuro
@@ -18,16 +19,21 @@ module Zakuro
18
19
  # @return [True] リリースあり
19
20
  RELEASE = true
20
21
 
22
+ # @return [String] 暦クラス名
23
+ VERSION_NAME = 'Senmyou'
24
+
21
25
  #
22
26
  # 西暦日から和暦日に変換する
23
27
  #
24
28
  # @param [Date] western_date 西暦日
25
29
  #
26
- # @return [Result::SingleDay] 和暦日
30
+ # @return [Result::Single] 和暦日
27
31
  #
28
32
  def self.to_japan_date(western_date:)
29
33
  date = Western::Calendar.create(date: western_date)
30
- Single.get(date: date)
34
+
35
+ context = Context.new(version_name: VERSION_NAME)
36
+ Calculation::Summary::Single.get(context: context, date: date)
31
37
  end
32
38
  end
33
39
  end
@@ -0,0 +1,237 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../const/number'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ # :nodoc:
8
+ module Senmyou
9
+ # :nodoc:
10
+ module Lunar
11
+ #
12
+ # Adjustment 補正値情報
13
+ #
14
+ module Adjustment
15
+ # @return [Integer] 遠/近の地点での中間
16
+ HALF_DAYS = [7].freeze
17
+
18
+ #
19
+ # Row 行情報
20
+ #
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
31
+
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
46
+
47
+ # :reek:ControlParameter
48
+
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
+ return false unless @forward == forward
61
+
62
+ return false unless @day == day
63
+
64
+ return false unless @range.include?(minute: minute)
65
+
66
+ true
67
+ end
68
+
69
+ #
70
+ # 分母を返す
71
+ #
72
+ # @return [Integer] 分母
73
+ #
74
+ def denominator
75
+ @range.denominator
76
+ end
77
+ end
78
+
79
+ #
80
+ # Range 小余範囲
81
+ #
82
+ class Range
83
+ # @return [Integer] 下限
84
+ MIN = 0
85
+ # @return [Integer] 上限
86
+ MAX = Const::Number::Cycle::DAY
87
+ # @return [Integer] 遠/近の地点での中間
88
+ HALF = 7465
89
+ # @return [Integer] 各地点の最後
90
+ LAST = 6529
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
107
+
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
119
+
120
+ #
121
+ # 分母を返す
122
+ #
123
+ # @return [Integer] 分母
124
+ #
125
+ def denominator
126
+ @max - @min
127
+ end
128
+ end
129
+
130
+ #
131
+ # Value 補正値
132
+ #
133
+ class Value
134
+ # @return [Integer] 損益率
135
+ attr_reader :per
136
+ # @return [Integer] 眺朒(ちょうじく)積
137
+ attr_reader :stack
138
+
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
149
+
150
+ #
151
+ # 文字化
152
+ #
153
+ # @return [String] 文字
154
+ #
155
+ def to_s
156
+ "per:#{@per}, stack:#{@stack}"
157
+ end
158
+ end
159
+
160
+ # rubocop:disable Layout/LineLength
161
+
162
+ #
163
+ # @return [Array<Row>] 月の補正値情報
164
+ #
165
+ LIST = [
166
+ Row.new(forward: true, day: 1, range: Range.new, value: Value.new(per: +830, stack: 0)),
167
+ Row.new(forward: true, day: 2, range: Range.new, value: Value.new(per: +726, stack: +830)),
168
+ Row.new(forward: true, day: 3, range: Range.new, value: Value.new(per: +606, stack: +1556)),
169
+ Row.new(forward: true, day: 4, range: Range.new, value: Value.new(per: +471, stack: +2162)),
170
+ Row.new(forward: true, day: 5, range: Range.new, value: Value.new(per: +337, stack: +2633)),
171
+ Row.new(forward: true, day: 6, range: Range.new, value: Value.new(per: +202, stack: +2970)),
172
+ Row.new(forward: true, day: 7, range: Range.new(max: Range::HALF), value: Value.new(per: +53, stack: +3172)),
173
+ Row.new(forward: true, day: 7, range: Range.new(min: Range::HALF), value: Value.new(per: -7, stack: +3225)), # +3172 + 53(初益)
174
+ Row.new(forward: true, day: 8, range: Range.new, value: Value.new(per: -82, stack: +3218)),
175
+ Row.new(forward: true, day: 9, range: Range.new, value: Value.new(per: -224, stack: +3136)),
176
+ Row.new(forward: true, day: 10, range: Range.new, value: Value.new(per: -366, stack: +2912)),
177
+ Row.new(forward: true, day: 11, range: Range.new, value: Value.new(per: -509, stack: +2546)),
178
+ Row.new(forward: true, day: 12, range: Range.new, value: Value.new(per: -643, stack: +2037)),
179
+ Row.new(forward: true, day: 13, range: Range.new, value: Value.new(per: -748, stack: +1394)),
180
+ Row.new(forward: true, day: 14, range: Range.new(max: Range::LAST), value: Value.new(per: -646, stack: +646)), # 14日の小余は常に6529以下
181
+ Row.new(forward: false, day: 1, range: Range.new, value: Value.new(per: -830, stack: 0)),
182
+ Row.new(forward: false, day: 2, range: Range.new, value: Value.new(per: -726, stack: -830)),
183
+ Row.new(forward: false, day: 3, range: Range.new, value: Value.new(per: -598, stack: -1556)),
184
+ Row.new(forward: false, day: 4, range: Range.new, value: Value.new(per: -464, stack: -2154)),
185
+ Row.new(forward: false, day: 5, range: Range.new, value: Value.new(per: -329, stack: -2618)),
186
+ Row.new(forward: false, day: 6, range: Range.new, value: Value.new(per: -195, stack: -2947)),
187
+ Row.new(forward: false, day: 7, range: Range.new(max: Range::HALF), value: Value.new(per: -53, stack: -3142)),
188
+ Row.new(forward: false, day: 7, range: Range.new(min: Range::HALF), value: Value.new(per: +7, stack: -3195)), # -3142 - 53(初益)
189
+ Row.new(forward: false, day: 8, range: Range.new, value: Value.new(per: +82, stack: -3188)),
190
+ Row.new(forward: false, day: 9, range: Range.new, value: Value.new(per: +225, stack: -3106)),
191
+ Row.new(forward: false, day: 10, range: Range.new, value: Value.new(per: +366, stack: -2881)),
192
+ Row.new(forward: false, day: 11, range: Range.new, value: Value.new(per: +501, stack: -2515)),
193
+ Row.new(forward: false, day: 12, range: Range.new, value: Value.new(per: +628, stack: -2014)),
194
+ Row.new(forward: false, day: 13, range: Range.new, value: Value.new(per: +740, stack: -1386)),
195
+ Row.new(forward: false, day: 14, range: Range.new(max: Range::LAST), value: Value.new(per: +646, stack: -646)) # 14日の小余は常に6529以下
196
+ ].freeze
197
+ # rubocop:enable Layout/LineLength
198
+
199
+ #
200
+ # 月軌道の補正に必要な基本値を引き当てる
201
+ #
202
+ # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
203
+ # @param [Integer] day 大余
204
+ # @param [Integer] minute 小余
205
+ #
206
+ # @return [Row] 補正値
207
+ #
208
+ def self.specify(forward:, day:, minute:)
209
+ LIST.each do |row|
210
+ # NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
211
+ return row if row.match?(forward: forward, day: day, minute: minute)
212
+ end
213
+
214
+ raise ArgumentError.new, "invalid parameter: #{forward}/#{day}/#{minute}"
215
+ end
216
+
217
+ # :reek:ControlParameter
218
+
219
+ #
220
+ # 小余の下げ幅を求める
221
+ #
222
+ # @param [Integer] day 大余
223
+ # @param [Integer] minute 小余
224
+ #
225
+ # @return [Integer] 小余の下げ幅
226
+ #
227
+ def self.minus_minute(day:, minute:)
228
+ return minute unless HALF_DAYS.include?(day)
229
+
230
+ return minute unless minute > Range::HALF
231
+
232
+ minute - Range::HALF
233
+ end
234
+ end
235
+ end
236
+ end
237
+ end