zakuro 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) 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 +471 -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 +76 -0
  22. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +52 -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/merchant.rb +2 -2
  29. data/lib/zakuro/operation/month/parser.rb +1 -1
  30. data/lib/zakuro/operation/month/type.rb +5 -10
  31. data/lib/zakuro/output/error.rb +7 -6
  32. data/lib/zakuro/output/logger.rb +50 -49
  33. data/lib/zakuro/output/response.rb +145 -144
  34. data/lib/zakuro/tools/typeof.rb +2 -2
  35. data/lib/zakuro/version.rb +1 -1
  36. data/lib/zakuro/version/abstract_version.rb +1 -1
  37. data/lib/zakuro/version/context.rb +23 -0
  38. data/lib/zakuro/version/gihou/const/number.rb +55 -0
  39. data/lib/zakuro/version/gihou/const/remainder.rb +56 -0
  40. data/lib/zakuro/version/gihou/cycle/remainder.rb +61 -0
  41. data/lib/zakuro/version/gihou/cycle/solar_term.rb +34 -0
  42. data/lib/zakuro/version/gihou/gihou.rb +23 -2
  43. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +106 -0
  44. data/lib/zakuro/version/gihou/range/annual_range.rb +39 -0
  45. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +250 -0
  46. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +44 -0
  47. data/lib/zakuro/version/gihou/stella/lunar/location.rb +86 -0
  48. data/lib/zakuro/version/gihou/stella/lunar/value.rb +74 -0
  49. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +34 -0
  50. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +62 -0
  51. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +55 -0
  52. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +93 -0
  53. data/lib/zakuro/version/gihou/stella/solar/average.rb +97 -0
  54. data/lib/zakuro/version/gihou/stella/solar/interval.rb +108 -0
  55. data/lib/zakuro/version/gihou/stella/solar/location.rb +61 -0
  56. data/lib/zakuro/version/gihou/stella/solar/value.rb +36 -0
  57. data/lib/zakuro/version/senmyou/const/number.rb +51 -0
  58. data/lib/zakuro/version/senmyou/const/remainder.rb +49 -0
  59. data/lib/zakuro/version/senmyou/cycle/remainder.rb +61 -0
  60. data/lib/zakuro/version/senmyou/cycle/solar_term.rb +34 -0
  61. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +80 -195
  62. data/lib/zakuro/version/senmyou/range/annual_range.rb +25 -170
  63. data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
  64. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
  65. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +44 -0
  66. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +93 -0
  67. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +66 -0
  68. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
  69. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
  70. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
  71. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
  72. data/lib/zakuro/version/senmyou/stella/solar/average.rb +97 -0
  73. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
  74. data/lib/zakuro/version/senmyou/stella/solar/location.rb +61 -0
  75. data/lib/zakuro/version/senmyou/stella/solar/value.rb +39 -0
  76. data/lib/zakuro/version/version_class_resolver.rb +66 -0
  77. data/lib/zakuro/version_factory.rb +2 -2
  78. metadata +64 -24
  79. data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
  80. data/lib/zakuro/cycle/zodiac.rb +0 -103
  81. data/lib/zakuro/version/senmyou/base/era.rb +0 -83
  82. data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
  83. data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
  84. data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
  85. data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -86
  86. data/lib/zakuro/version/senmyou/base/year.rb +0 -104
  87. data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
  88. data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -48
  89. data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
  90. data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
  91. data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -167
  92. data/lib/zakuro/version/senmyou/range/full_range.rb +0 -324
  93. data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -126
  94. data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -181
  95. data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -102
  96. data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
  97. data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -214
  98. data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -394
  99. data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
  100. data/lib/zakuro/version/senmyou/summary/single.rb +0 -125
@@ -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 Senmyou
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
@@ -1,219 +1,104 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../../output/logger'
3
+ require_relative '../../../calculation/monthly/abstract_lunar_phase'
4
4
 
5
- require_relative '../stella/winter_solstice'
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'
6
14
 
7
15
  # :nodoc:
8
16
  module Zakuro
9
17
  # :nodoc:
10
18
  module Senmyou
11
- # :reek:TooManyStatements { max_statements: 7 }
12
- # :reek:TooManyInstanceVariables { max_instance_variables: 7 }
13
-
14
- #
15
- # LunarPhase 月の位相
16
- #
17
- class LunarPhase
18
- #
19
- # QuarterMoon 弦
20
- #
21
- module QuarterMoon
22
- # @return [Remainder] 弦(1分=8秒)
23
- DEFAULT = Remainder.new(day: 7, minute: 3214, second: 2)
24
- # @return [Remainder] 弦(1分=100秒)
25
- BASE_HUNDRED = LunarRemainder.new(day: 7, minute: 3214, second: 25)
26
- end
27
-
28
- # @return [Logger] ロガー
29
- LOGGER = Logger.new(location: 'lunar_phase')
30
-
31
- # @return [Array<String>] 月内の弦
32
- PHASE_INDEXES = %w[朔日 上弦 望月 下弦].freeze
33
-
34
- # @return [Integer] 西暦年
35
- attr_reader :western_year
36
- # @return [Remainder]] 経
37
- attr_reader :average_remainder
38
- # @return [True] 初回計算
39
- # @return [False] 次回以降計算
40
- attr_reader :first
41
- # @return [SolarTerm] 二十四節気(入定気)
42
- attr_reader :solar_term
43
- # @return [Remainder] 入暦
44
- attr_reader :moon_remainder
45
- # @return [True] 進(遠地点より数える)
46
- # @return [False] 退(近地点より数える)
47
- attr_reader :is_forward
48
- # @return [Integer] 弦
49
- attr_reader :phase_index
50
-
51
- #
52
- # 初期化
53
- #
54
- # @param [Integer] western_year 西暦年
55
- #
56
- def initialize(western_year:)
57
- @western_year = western_year
58
- # 経
59
- @average_remainder = WinterSolstice.calc_averaged_last_november_1st(
60
- western_year: @western_year
61
- )
62
- # 天正冬至
63
- winter_solstice_age = \
64
- WinterSolstice.calc_moon_age(western_year: @western_year)
65
- # 入定気
66
- @solar_term = SolarTerm.new(remainder: winter_solstice_age)
67
- # 入暦
68
- @moon_remainder = LunarRemainder.new(total: 0).add!(winter_solstice_age)
69
-
70
- @is_forward = false
71
- @first = true
72
-
73
- # 弦
74
- @phase_index = 0
75
- end
76
-
77
- #
78
- # 次の弦に進める
79
- #
80
- # @return [Remainder] 定朔
81
- #
82
- def next_phase
83
- adjusted = current_remainder
84
-
85
- @first = false if @first
86
-
87
- add_quarter_moon_size
88
-
89
- adjusted
90
- end
91
-
92
- #
93
- # 次の月に進める
94
- # @note 進めた後の月の定朔ではなく、当月のものを返却する
95
- #
96
- # @return [Remainder] 当月初の定朔
97
- #
98
- def next_month
99
- result = nil
100
- PHASE_INDEXES.each_with_index do |_phase, index|
101
- adjust = next_phase
102
- result = adjust if index.zero?
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
+ )
103
46
  end
104
47
 
105
- result
106
- end
107
-
108
- private
109
-
110
- #
111
- # 次の弦に進める
112
- #
113
- # @return [Integer] 弦
114
- #
115
- def next_phase_index
116
- @phase_index += 1
117
- @phase_index = 0 if @phase_index >= PHASE_INDEXES.size
118
- @phase_index
119
- end
120
-
121
- #
122
- # 朔月(月初)かを確認する
123
- #
124
- # @return [True] 朔月である
125
- # @return [False] 朔月ではない
126
- #
127
- def first_phase?
128
- @phase_index.zero?
129
- end
130
-
131
- #
132
- # 朔月のみログ出力する
133
- #
134
- # @param [String] messages メッセージ(可変長)
135
- #
136
- def debug(*messages)
137
- return unless first_phase?
138
-
139
- LOGGER.debug(*messages)
140
- end
48
+ private
141
49
 
142
- #
143
- # 現在の定朔を取得する
144
- #
145
- # @return [Remainder] 定朔
146
- #
147
- def current_remainder
148
- debug("@average_remainder.format: #{@average_remainder.format}")
50
+ # :reek:TooManyStatements { max_statements: 6 }
149
51
 
150
- sum = correction_value
151
- adjusted = @average_remainder.add(
152
- Remainder.new(day: 0, minute: sum, second: 0)
153
- )
154
- adjusted.up_on_new_moon!
52
+ #
53
+ # 現在の定朔を取得する
54
+ #
55
+ # @return [Remainder] 定朔
56
+ #
57
+ def current_remainder
58
+ debug("@average_remainder.format: #{@average_remainder.format}")
155
59
 
156
- debug("result: #{adjusted.format}")
60
+ sum = correction_value
61
+ adjusted = @average_remainder.add(
62
+ Cycle::Remainder.new(day: 0, minute: sum, second: 0)
63
+ )
64
+ adjusted.up_on_new_moon!
157
65
 
158
- adjusted
159
- end
66
+ debug("result: #{adjusted.format}")
160
67
 
161
- #
162
- # 補正値を得る
163
- #
164
- # @return [Integer] 補正値
165
- #
166
- def correction_value
167
- sun = correction_solar_value
168
- moon = correction_moon_value
68
+ adjusted
69
+ end
169
70
 
170
- sum = sun + moon
71
+ #
72
+ # 太陽運動の補正値を得る
73
+ #
74
+ # @return [Integer] 太陽運動の補正値
75
+ #
76
+ def correction_solar_value
77
+ @solar_location.run
78
+ debug("@solar_term.remainder: #{@solar_location.remainder.format(form: '%d-%d.%d')}")
79
+ debug("@solar_term.index: #{@solar_location.index}")
80
+
81
+ Solar::Value.get(solar_location: @solar_location)
82
+ end
171
83
 
172
- debug("sun: #{sun}", "moon: #{moon}", "sun + moon : #{sum}")
84
+ # :reek:TooManyStatements { max_statements: 6 }
173
85
 
174
- sum
175
- end
86
+ #
87
+ # 月運動の補正値を得る
88
+ #
89
+ # @return [Integer] 月運動の補正値
90
+ #
91
+ def correction_moon_value
92
+ @lunar_location.run
176
93
 
177
- #
178
- # 太陽運動の補正値を得る
179
- #
180
- # @return [Integer] 太陽運動の補正値
181
- #
182
- def correction_solar_value
183
- @solar_term = SolarOrbit.calc_solar_term_by_remainder(
184
- solar_term: @solar_term
185
- )
186
- debug("@solar_term.remainder: #{@solar_term.remainder.format(form: '%d-%d.%d')}")
187
- debug("@solar_term.index: #{@solar_term.index}")
188
-
189
- SolarOrbit.calc_sun_orbit_value(solar_term: @solar_term)
190
- end
94
+ remainder = @lunar_location.remainder
95
+ forward = @lunar_location.forward
191
96
 
192
- #
193
- # 月運動の補正値を得る
194
- #
195
- # @return [Integer] 月運動の補正値
196
- #
197
- def correction_moon_value
198
- @moon_remainder, @is_forward = \
199
- LunarOrbit.calc_moon_point(remainder: @moon_remainder,
200
- western_year: @western_year,
201
- is_forward: @is_forward,
202
- first: @first)
203
-
204
- debug("@moon_remainder.format: #{@moon_remainder.format}")
205
- debug("@is_forward: #{@is_forward}")
206
-
207
- LunarOrbit.calc_moon_orbit_value(remainder_month: @moon_remainder,
208
- is_forward: @is_forward)
209
- end
210
-
211
- def add_quarter_moon_size
212
- @average_remainder.add!(QuarterMoon::DEFAULT)
213
- @solar_term.remainder.add!(QuarterMoon::DEFAULT)
214
- @moon_remainder.add!(QuarterMoon::BASE_HUNDRED)
97
+ debug("[lunar]remainder.format: #{remainder.format}")
98
+ debug("[lunar]forward: #{forward}")
215
99
 
216
- next_phase_index
100
+ Lunar::Value.get(remainder: remainder, forward: forward)
101
+ end
217
102
  end
218
103
  end
219
104
  end
@@ -1,184 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../../output/logger'
4
- require_relative '../base/remainder'
5
- require_relative '../monthly/initialized_month'
6
- require_relative '../base/solar_term'
3
+ require_relative '../../../calculation/range/medieval_annual_range'
7
4
  require_relative '../monthly/lunar_phase'
8
- require_relative '../stella/solar_orbit'
9
- require_relative '../stella/solar_average'
10
- require_relative '../stella/lunar_orbit'
5
+ require_relative '../stella/solar/average'
11
6
 
12
7
  # :nodoc:
13
8
  module Zakuro
14
9
  # :nodoc:
15
10
  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
- # 一覧取得する
58
- #
59
- # * 対象年に対して、前年11月-当年11月までを出力する
60
- # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
61
- #
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)
70
-
71
- SolarAverage.set_solar_terms_into_annual_range(western_year: western_year,
72
- annual_range: annual_range)
73
-
74
- # 月間隔を取得するためだけの末尾要素を削除
75
- annual_range.pop
76
-
77
- adjust_leap_month(annual_range: annual_range)
78
-
79
- annual_range
80
- end
81
-
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
- )
99
-
100
- moon_remainder, is_forward = LunarOrbit.calc_moon_point(
101
- remainder: winter_solstice_age, western_year: western_year
102
- )
103
-
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
109
-
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)
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
134
34
  )
135
- is_last_year = false if month == 12
136
- end
137
- result
138
- end
139
- private_class_method :initialized_annual_range
140
-
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)
153
- 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
179
35
  end
180
36
  end
181
- private_class_method :adjust_leap_month
182
37
  end
183
38
  end
184
39
  end