zakuro 0.1.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
  3. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
  4. data/lib/zakuro/calculation/base/year.rb +107 -0
  5. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +484 -0
  6. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
  7. data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
  8. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +169 -0
  9. data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
  10. data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
  11. data/lib/zakuro/calculation/monthly/month.rb +187 -0
  12. data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
  13. data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
  14. data/lib/zakuro/calculation/range/full_range.rb +210 -0
  15. data/lib/zakuro/calculation/range/medieval_annual_range.rb +105 -0
  16. data/lib/zakuro/calculation/range/operated_range.rb +144 -0
  17. data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
  18. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
  19. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
  20. data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
  21. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +78 -0
  22. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +71 -0
  23. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +117 -0
  24. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +187 -0
  25. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +136 -0
  26. data/lib/zakuro/calculation/summary/single.rb +129 -0
  27. data/lib/zakuro/calculation/type/old_float.rb +69 -0
  28. data/lib/zakuro/era/japan/reki.rb +1 -1
  29. data/lib/zakuro/merchant.rb +2 -2
  30. data/lib/zakuro/output/error.rb +7 -6
  31. data/lib/zakuro/output/logger.rb +50 -49
  32. data/lib/zakuro/output/response.rb +145 -144
  33. data/lib/zakuro/tools/typeof.rb +2 -2
  34. data/lib/zakuro/version.rb +1 -1
  35. data/lib/zakuro/version/abstract_version.rb +1 -1
  36. data/lib/zakuro/version/context.rb +23 -0
  37. data/lib/zakuro/version/daien/const/number.rb +55 -0
  38. data/lib/zakuro/version/daien/const/remainder.rb +53 -0
  39. data/lib/zakuro/version/daien/cycle/remainder.rb +59 -0
  40. data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
  41. data/lib/zakuro/version/daien/daien.rb +36 -0
  42. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
  43. data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
  44. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
  45. data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
  46. data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
  47. data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
  48. data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
  49. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
  50. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
  51. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
  52. data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
  53. data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
  54. data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
  55. data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
  56. data/lib/zakuro/version/gihou/const/number.rb +55 -0
  57. data/lib/zakuro/version/gihou/const/remainder.rb +54 -0
  58. data/lib/zakuro/version/gihou/cycle/remainder.rb +56 -0
  59. data/lib/zakuro/version/gihou/cycle/solar_term.rb +34 -0
  60. data/lib/zakuro/version/gihou/gihou.rb +23 -2
  61. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +106 -0
  62. data/lib/zakuro/version/gihou/range/annual_range.rb +39 -0
  63. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +250 -0
  64. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +44 -0
  65. data/lib/zakuro/version/gihou/stella/lunar/location.rb +80 -0
  66. data/lib/zakuro/version/gihou/stella/lunar/value.rb +75 -0
  67. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +34 -0
  68. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +62 -0
  69. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +55 -0
  70. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +93 -0
  71. data/lib/zakuro/version/gihou/stella/solar/average.rb +97 -0
  72. data/lib/zakuro/version/gihou/stella/solar/interval.rb +108 -0
  73. data/lib/zakuro/version/gihou/stella/solar/location.rb +61 -0
  74. data/lib/zakuro/version/gihou/stella/solar/value.rb +36 -0
  75. data/lib/zakuro/version/senmyou/const/number.rb +51 -0
  76. data/lib/zakuro/version/senmyou/const/remainder.rb +47 -0
  77. data/lib/zakuro/version/senmyou/cycle/remainder.rb +56 -0
  78. data/lib/zakuro/version/senmyou/cycle/solar_term.rb +34 -0
  79. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +80 -195
  80. data/lib/zakuro/version/senmyou/range/annual_range.rb +25 -145
  81. data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
  82. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
  83. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +44 -0
  84. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +87 -0
  85. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +67 -0
  86. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
  87. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
  88. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
  89. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
  90. data/lib/zakuro/version/senmyou/stella/solar/average.rb +97 -0
  91. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
  92. data/lib/zakuro/version/senmyou/stella/solar/location.rb +61 -0
  93. data/lib/zakuro/version/senmyou/stella/solar/value.rb +39 -0
  94. data/lib/zakuro/version/version_class_resolver.rb +70 -0
  95. data/lib/zakuro/version_factory.rb +3 -3
  96. metadata +83 -28
  97. data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
  98. data/lib/zakuro/cycle/zodiac.rb +0 -103
  99. data/lib/zakuro/version/senmyou/base/era.rb +0 -83
  100. data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
  101. data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
  102. data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
  103. data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -148
  104. data/lib/zakuro/version/senmyou/base/year.rb +0 -104
  105. data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
  106. data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -119
  107. data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
  108. data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
  109. data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -196
  110. data/lib/zakuro/version/senmyou/range/full_range.rb +0 -194
  111. data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -126
  112. data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -181
  113. data/lib/zakuro/version/senmyou/range/western_date_allocation.rb +0 -68
  114. data/lib/zakuro/version/senmyou/range/year_boundary.rb +0 -138
  115. data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -102
  116. data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
  117. data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -169
  118. data/lib/zakuro/version/senmyou/stella/solar_location.rb +0 -213
  119. data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -213
  120. data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
  121. data/lib/zakuro/version/senmyou/summary/single.rb +0 -125
  122. data/lib/zakuro/version/taien/taien.rb +0 -19
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../calculation/cycle/abstract_remainder'
4
+
5
+ require_relative '../const/number'
6
+
7
+ # :nodoc:
8
+ module Zakuro
9
+ # :nodoc:
10
+ module Daien
11
+ # :nodoc:
12
+ module Cycle
13
+ #
14
+ # Remainder 時刻情報(大余小余)
15
+ #
16
+ class Remainder < Calculation::Cycle::AbstractRemainder
17
+ # 『歴代天文律暦等志彙編 七』中華書房 p.2056
18
+ # 「象統;二十四」「其秒盈象統,従小餘」
19
+ # 上記は舊唐志の記述だが、新唐志(p.2218)でも同様であることを確認した
20
+ # @return [Integer] 分(1分=24秒)
21
+ MINUTE = 24
22
+
23
+ #
24
+ # 初期化
25
+ #
26
+ # @param [Integer] day 大余("日"に相当)
27
+ # @param [Integer] minute 小余("分"に相当)
28
+ # @param [Integer] second 秒
29
+ # @param [Integer] total 繰り上げなしの小余
30
+ #
31
+ def initialize(day: -1, minute: -1, second: -1, total: -1)
32
+ super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
33
+ day: day, minute: minute, second: second, total: total)
34
+ end
35
+ end
36
+
37
+ #
38
+ # LunarRemainder 月の位相計算向け時刻情報(大余小余)
39
+ #
40
+ class LunarRemainder < Calculation::Cycle::AbstractRemainder
41
+ # @return [Integer] 分(1分=80秒)
42
+ MINUTE = 80
43
+
44
+ #
45
+ # 初期化
46
+ #
47
+ # @param [Integer] day 大余("日"に相当)
48
+ # @param [Integer] minute 小余("分"に相当)
49
+ # @param [Integer] second 秒
50
+ # @param [Integer] total 繰り上げなしの小余
51
+ #
52
+ def initialize(day: -1, minute: -1, second: -1, total: -1)
53
+ super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
54
+ day: day, minute: minute, second: second, total: total)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../calculation/cycle/abstract_solar_term'
4
+
5
+ require_relative '../const/remainder'
6
+
7
+ require_relative './remainder'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Daien
13
+ # :nodoc:
14
+ module Cycle
15
+ #
16
+ # SolarTerm 二十四節気
17
+ #
18
+ class SolarTerm < Calculation::Cycle::AbstractSolarTerm
19
+ # @return [Remainder] 気策(24分の1年)
20
+ SOLAR_TERM_AVERAGE = Const::Remainder::Solar::SOLAR_TERM_AVERAGE
21
+
22
+ #
23
+ # 初期化
24
+ #
25
+ # @param [Integer] index 連番
26
+ # @param [Remainder] remainder 時刻情報(大余小余)
27
+ #
28
+ def initialize(index: -1, remainder: Remainder.new)
29
+ super(index: index, remainder: remainder, average: SOLAR_TERM_AVERAGE)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../abstract_version'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ #
8
+ # Daien 大衍暦
9
+ #
10
+ module Daien
11
+ #
12
+ # Gateway アクセサメソッド群
13
+ #
14
+ class Gateway < AbstractVersion
15
+ # @return [True] リリースあり
16
+ RELEASE = true
17
+
18
+ # @return [String] 暦クラス名
19
+ VERSION_NAME = 'Daien'
20
+
21
+ #
22
+ # 西暦日から和暦日に変換する
23
+ #
24
+ # @param [Date] western_date 西暦日
25
+ #
26
+ # @return [Result::Single] 和暦日
27
+ #
28
+ def self.to_japan_date(western_date:)
29
+ date = Western::Calendar.create(date: western_date)
30
+
31
+ context = Context.new(version_name: VERSION_NAME)
32
+ Calculation::Summary::Single.get(context: context, date: date)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../calculation/monthly/abstract_lunar_phase'
4
+
5
+ require_relative '../const/remainder'
6
+
7
+ require_relative '../stella/solar/location'
8
+ require_relative '../stella/solar/value'
9
+ require_relative '../stella/lunar/location'
10
+ require_relative '../stella/lunar/value'
11
+
12
+ require_relative '../stella/origin/lunar_age'
13
+ require_relative '../stella/origin/average_november'
14
+
15
+ # :nodoc:
16
+ module Zakuro
17
+ # :nodoc:
18
+ module Daien
19
+ # :nodoc:
20
+ module Monthly
21
+ #
22
+ # LunarPhase 月の位相
23
+ #
24
+ class LunarPhase < Calculation::Monthly::AbstractLunarPhase
25
+ # @return [Cycle::Remainder] 弦
26
+ QUARTER = Const::Remainder::Solar::QUARTER
27
+
28
+ #
29
+ # 初期化
30
+ #
31
+ # @param [Integer] western_year 西暦年
32
+ #
33
+ def initialize(western_year:)
34
+ # 天正閏余
35
+ lunar_age = Origin::LunarAge.get(western_year: western_year)
36
+
37
+ super(
38
+ quater: QUARTER,
39
+ average_remainder: Origin::AverageNovember.get(western_year: western_year),
40
+ solar_location: Solar::Location.new(lunar_age: lunar_age),
41
+ lunar_location: Lunar::Location.new(
42
+ western_year: western_year,
43
+ lunar_age: Cycle::LunarRemainder.new(total: 0).add!(lunar_age)
44
+ )
45
+ )
46
+ end
47
+
48
+ private
49
+
50
+ # :reek:TooManyStatements { max_statements: 6 }
51
+
52
+ #
53
+ # 現在の定朔を取得する
54
+ #
55
+ # @return [Remainder] 定朔
56
+ #
57
+ def current_remainder
58
+ # debug("@average_remainder.format: #{@average_remainder.format(form: '%d-%d-%.5f')}")
59
+
60
+ sum = correction_value
61
+ adjusted = @average_remainder.add(
62
+ Cycle::Remainder.new(day: 0, minute: sum, second: 0)
63
+ )
64
+ # TODO: 大衍暦では進朔するか
65
+ # adjusted.up_on_new_moon!
66
+
67
+ debug("result: #{adjusted.format}")
68
+
69
+ adjusted
70
+ end
71
+
72
+ #
73
+ # 太陽運動の補正値を得る
74
+ #
75
+ # @return [Integer] 太陽運動の補正値
76
+ #
77
+ def correction_solar_value
78
+ @solar_location.run
79
+ # debug("@solar_term.remainder: #{@solar_location.remainder.format(form: '%d-%d-%.5f')}")
80
+ # debug("@solar_term.index: #{@solar_location.index}")
81
+
82
+ Solar::Value.get(solar_location: @solar_location)
83
+ end
84
+
85
+ # :reek:TooManyStatements { max_statements: 6 }
86
+
87
+ #
88
+ # 月運動の補正値を得る
89
+ #
90
+ # @return [Integer] 月運動の補正値
91
+ #
92
+ def correction_moon_value
93
+ @lunar_location.run
94
+
95
+ remainder = @lunar_location.adjusted_remainder
96
+
97
+ # debug("[lunar]remainder.format: #{remainder.format(form: '%d-%d-%.5f')}")
98
+ # debug("[lunar]remainder.day: #{remainder.day}")
99
+ # debug("[lunar]remainder.minute: #{remainder.minute}")
100
+
101
+ Lunar::Value.get(remainder: remainder)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../calculation/range/medieval_annual_range'
4
+ require_relative '../monthly/lunar_phase'
5
+ require_relative '../stella/solar/average'
6
+
7
+ # :nodoc:
8
+ module Zakuro
9
+ # :nodoc:
10
+ module Daien
11
+ # :nodoc:
12
+ module Range
13
+ #
14
+ # AnnualRange 年間範囲
15
+ #
16
+ module AnnualRange
17
+ #
18
+ # 一覧取得する
19
+ #
20
+ # * 対象年に対して、前年11月-当年11月までを出力する
21
+ # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
22
+ #
23
+ # @param [Context] context 暦コンテキスト
24
+ # @param [Integer] western_year 西暦年
25
+ #
26
+ # @return [Array<Month>] 1年データ
27
+ #
28
+ def self.get(context:, western_year:)
29
+ lunar_phase = Monthly::LunarPhase.new(western_year: western_year)
30
+ solar_average = Solar::Average.new(western_year: western_year)
31
+
32
+ Calculation::Range::MedievalAnnualRange.get(
33
+ context: context, lunar_phase: lunar_phase, solar_average: solar_average
34
+ )
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,240 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../const/number'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ # :nodoc:
8
+ module Daien
9
+ # :nodoc:
10
+ module Lunar
11
+ #
12
+ # Adjustment 補正値情報
13
+ #
14
+ module Adjustment
15
+ # 『歴代天文律暦等志彙編 七』中華書房 p.2230
16
+ #
17
+ # 遠/近の地点での中間
18
+ #
19
+ # @return [Hash<Integer>] 遠/近の地点での中間
20
+ DAY_LIMIT = {
21
+ 7 => 2701,
22
+ 14 => 2363,
23
+ 21 => 2024,
24
+ 28 => 1686
25
+ }.freeze
26
+
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
37
+
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
50
+
51
+ # :reek:ControlParameter
52
+
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
+ return false unless @day == day
64
+
65
+ return false unless @range.include?(minute: minute)
66
+
67
+ true
68
+ end
69
+
70
+ #
71
+ # 分母を返す
72
+ #
73
+ # @return [Integer] 分母
74
+ #
75
+ def denominator
76
+ @range.denominator
77
+ end
78
+ end
79
+
80
+ #
81
+ # Range 小余範囲
82
+ #
83
+ class Range
84
+ # @return [Integer] 下限
85
+ MIN = 0
86
+ # @return [Integer] 上限
87
+ MAX = Const::Number::Cycle::DAY
88
+
89
+ # @return [Integer] 下限
90
+ attr_reader :min
91
+ # @return [Integer] 上限
92
+ attr_reader :max
93
+
94
+ #
95
+ # 初期化
96
+ #
97
+ # @param [Integer] min 下限
98
+ # @param [Integer] max 上限
99
+ #
100
+ def initialize(min: MIN, max: MAX)
101
+ @min = min
102
+ @max = max
103
+ end
104
+
105
+ #
106
+ # 含まれるか
107
+ #
108
+ # @param [Integer] minute 小余
109
+ #
110
+ # @return [True] 含まれる
111
+ # @return [False] 含まれない
112
+ #
113
+ def include?(minute:)
114
+ minute >= @min && minute <= @max
115
+ end
116
+
117
+ #
118
+ # 分母を返す
119
+ #
120
+ # @return [Integer] 分母
121
+ #
122
+ def denominator
123
+ @max - @min
124
+ end
125
+ end
126
+
127
+ #
128
+ # Value 補正値
129
+ #
130
+ class Value
131
+ # @return [Integer] 増減率
132
+ attr_reader :per
133
+ # @return [Integer] 遅速積
134
+ attr_reader :stack
135
+
136
+ #
137
+ # 初期化
138
+ #
139
+ # @param [Integer] per 増減率
140
+ # @param [Integer] stack 遅速積
141
+ #
142
+ def initialize(per:, stack:)
143
+ @per = per
144
+ @stack = stack
145
+ end
146
+
147
+ #
148
+ # 文字化
149
+ #
150
+ # @return [String] 文字
151
+ #
152
+ def to_s
153
+ "per:#{@per}, stack:#{@stack}"
154
+ end
155
+ end
156
+
157
+ # rubocop:disable Layout/LineLength
158
+
159
+ # 『歴代天文律暦等志彙編 七』中華書房 p.2228-2230
160
+ #
161
+ # @note 7日、14日、21日、28日の小余は DAY_LIMIT を参照のこと
162
+ #
163
+ # @return [Array<Row>] 月の補正値情報
164
+ #
165
+ LIST = [
166
+ Row.new(day: 1, range: Range.new, value: Value.new(per: +297, stack: 0)),
167
+ Row.new(day: 2, range: Range.new, value: Value.new(per: +259, stack: +297)),
168
+ Row.new(day: 3, range: Range.new, value: Value.new(per: +220, stack: +556)),
169
+ Row.new(day: 4, range: Range.new, value: Value.new(per: +180, stack: +776)),
170
+ Row.new(day: 5, range: Range.new, value: Value.new(per: +139, stack: +956)),
171
+ Row.new(day: 6, range: Range.new, value: Value.new(per: +97, stack: +1095)),
172
+ Row.new(day: 7, range: Range.new(max: DAY_LIMIT[7]), value: Value.new(per: +48, stack: +1192)),
173
+ Row.new(day: 7, range: Range.new(min: DAY_LIMIT[7]), value: Value.new(per: -6, stack: +1240)), # stack: +1192 + 48
174
+ Row.new(day: 8, range: Range.new, value: Value.new(per: -64, stack: +1234)),
175
+ Row.new(day: 9, range: Range.new, value: Value.new(per: -106, stack: +1170)),
176
+ Row.new(day: 10, range: Range.new, value: Value.new(per: -148, stack: +1064)),
177
+ Row.new(day: 11, range: Range.new, value: Value.new(per: -189, stack: +916)),
178
+ Row.new(day: 12, range: Range.new, value: Value.new(per: -229, stack: +727)),
179
+ Row.new(day: 13, range: Range.new, value: Value.new(per: -267, stack: +498)),
180
+ Row.new(day: 14, range: Range.new(max: DAY_LIMIT[14]), value: Value.new(per: -231, stack: +231)),
181
+ Row.new(day: 14, range: Range.new(min: DAY_LIMIT[14]), value: Value.new(per: -66, stack: 0)), # stack: +232 - 231
182
+ Row.new(day: 15, range: Range.new, value: Value.new(per: -289, stack: -66)),
183
+ Row.new(day: 16, range: Range.new, value: Value.new(per: -250, stack: -355)),
184
+ Row.new(day: 17, range: Range.new, value: Value.new(per: -211, stack: -605)),
185
+ Row.new(day: 18, range: Range.new, value: Value.new(per: -171, stack: -816)),
186
+ Row.new(day: 19, range: Range.new, value: Value.new(per: -130, stack: -987)),
187
+ Row.new(day: 20, range: Range.new, value: Value.new(per: -87, stack: -1117)),
188
+ Row.new(day: 21, range: Range.new(max: DAY_LIMIT[21]), value: Value.new(per: -36, stack: -1204)),
189
+ Row.new(day: 21, range: Range.new(min: DAY_LIMIT[21]), value: Value.new(per: +18, stack: -1240)), # stack: -1204 - 36
190
+ Row.new(day: 22, range: Range.new, value: Value.new(per: +73, stack: -1222)),
191
+ Row.new(day: 23, range: Range.new, value: Value.new(per: +116, stack: -1149)),
192
+ Row.new(day: 24, range: Range.new, value: Value.new(per: +157, stack: -1033)),
193
+ Row.new(day: 25, range: Range.new, value: Value.new(per: +198, stack: -876)),
194
+ Row.new(day: 26, range: Range.new, value: Value.new(per: +237, stack: -678)),
195
+ Row.new(day: 27, range: Range.new, value: Value.new(per: +276, stack: -441)),
196
+ Row.new(day: 28, range: Range.new(max: DAY_LIMIT[28]), value: Value.new(per: +165, stack: -165))
197
+ ].freeze
198
+ # rubocop:enable Layout/LineLength
199
+
200
+ #
201
+ # 月軌道の補正に必要な基本値を引き当てる
202
+ #
203
+ # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
204
+ # @param [Integer] day 大余
205
+ # @param [Integer] minute 小余
206
+ #
207
+ # @return [Row] 補正値
208
+ #
209
+ def self.specify(day:, minute:)
210
+ LIST.each do |row|
211
+ # NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
212
+ return row if row.match?(day: day, minute: minute)
213
+ end
214
+
215
+ raise ArgumentError.new, "invalid parameter: #{day}/#{minute}"
216
+ end
217
+
218
+ # :reek:ControlParameter
219
+
220
+ #
221
+ # 小余の下げ幅を求める
222
+ #
223
+ # @param [Integer] day 大余
224
+ # @param [Integer] minute 小余
225
+ #
226
+ # @return [Integer] 小余の下げ幅
227
+ #
228
+ def self.minus_minute(day:, minute:)
229
+ limit = DAY_LIMIT.fetch(day, -1)
230
+ # 該当なし
231
+ return minute if limit == -1
232
+
233
+ return minute unless minute > limit
234
+
235
+ minute - limit
236
+ end
237
+ end
238
+ end
239
+ end
240
+ end