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,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 = SolarLocation.get(
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.adjusted_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,159 +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/solar_location'
11
- require_relative '../stella/lunar_orbit'
5
+ require_relative '../stella/solar/average'
12
6
 
13
7
  # :nodoc:
14
8
  module Zakuro
15
9
  # :nodoc:
16
10
  module Senmyou
17
- #
18
- # AnnualRange 年間範囲
19
- #
20
- module AnnualRange
21
- # @return [Logger] ロガー
22
- LOGGER = Logger.new(location: 'annual_range')
23
-
24
- # :reek:TooManyStatements { max_statements: 6 }
25
-
26
- #
27
- # 11月定朔(冬至が含まれる月の1日:補正済)を求める
28
- #
29
- # @param [Integer] western_year 西暦年
30
- #
31
- # @return [Remainder] 11月定朔
32
- #
33
- def self.calc_last_november_1st(western_year:)
34
- # 天正閏余
35
- winter_solstice_age = \
36
- WinterSolstice.calc_moon_age(western_year: western_year)
37
- # 11月経朔
38
- november_1st = \
39
- WinterSolstice.calc_averaged_last_november_1st(western_year: western_year)
40
- # 11月定朔
41
-
42
- # 補正
43
- correction_value = correction_value_on_last_november_1st(
44
- winter_solstice_age: winter_solstice_age,
45
- western_year: western_year
46
- )
47
-
48
- result = november_1st.add(Remainder.new(day: 0, minute: correction_value,
49
- second: 0))
50
- # 進朔
51
- result.up_on_new_moon!
52
- result
53
- end
54
-
55
- # :reek:TooManyStatements { max_statements: 6 }
56
-
57
- #
58
- # 一覧取得する
59
- #
60
- # * 対象年に対して、前年11月-当年11月までを出力する
61
- # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
62
- #
63
- # @param [Integer] western_year 西暦年
64
- #
65
- # @return [Array<Month>] 1年データ
66
- #
67
- def self.collect_annual_range_after_last_november_1st(western_year:)
68
- annual_range = initialized_annual_range(western_year: western_year)
69
-
70
- apply_big_and_small_of_the_month(annual_range: annual_range)
71
-
72
- solar_average = SolarAverage.new(western_year: western_year)
73
- solar_average.set(annual_range: annual_range)
74
-
75
- # 月間隔を取得するためだけの末尾要素を削除
76
- annual_range.pop
77
-
78
- initialize_month_label(annual_range: annual_range)
79
- end
80
-
81
- #
82
- # 11月定朔の補正値を求める
83
- #
84
- # @param [Remainder] winter_solstice_age 天正閏余
85
- # @param [Integer] western_year 西暦年
86
- #
87
- # @return [Integer] 補正値
88
- #
89
- def self.correction_value_on_last_november_1st(winter_solstice_age:, western_year:)
90
- # 補正
91
- solar_term = SolarTerm.new(
92
- remainder: winter_solstice_age
93
- )
94
- solar_term = \
95
- SolarLocation.get(
96
- solar_term: solar_term
97
- )
98
-
99
- moon_remainder, is_forward = LunarOrbit.calc_moon_point(
100
- remainder: winter_solstice_age, western_year: western_year
101
- )
102
-
103
- SolarOrbit.calc_sun_orbit_value(solar_term: solar_term) +
104
- LunarOrbit.calc_moon_orbit_value(remainder_month: moon_remainder,
105
- is_forward: is_forward)
106
- end
107
- private_class_method :correction_value_on_last_november_1st
108
-
109
- #
110
- # 1年データを取得する
111
- #
112
- # @param [Integer] western_year 西暦年
113
- #
114
- # @return [Array<Month>] 1年データ
115
- #
116
- def self.initialized_annual_range(western_year:)
117
- result = []
118
- lunar_phase = LunarPhase.new(western_year: western_year)
119
-
120
- # 14ヶ月分を生成する(閏年で最大13ヶ月 + 末月の大小/二十四節気を求めるために必要な月)
121
- (0..13).each do |_index|
122
- adjusted = lunar_phase.next_month
123
-
124
- result.push(
125
- InitializedMonth.new(month_label: MonthLabel.new,
126
- first_day: FirstDay.new(remainder: adjusted),
127
- 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
128
34
  )
129
35
  end
130
-
131
- result
132
- end
133
- private_class_method :initialized_annual_range
134
-
135
- #
136
- # 1年データの各月に月の大小を設定する
137
- #
138
- # @param [Array<Month>] annual_range 1年データ
139
- #
140
- def self.apply_big_and_small_of_the_month(annual_range:)
141
- # NOTE: 最後の月は処理できない(=計算外の余分な月が最後に必要である)
142
- annual_range.each_cons(2) do |(current_month, next_month)|
143
- current_month.eval_many_days(next_month_day: next_month.remainder.day)
144
- end
145
- end
146
- private_class_method :apply_big_and_small_of_the_month
147
-
148
- #
149
- # 月表示情報を更新する
150
- #
151
- # @param [Array<Month>] annual_range 1年データ
152
- #
153
- def self.initialize_month_label(annual_range:)
154
- annual_range.each(&:rename_month_label_by_solar_term)
155
36
  end
156
- private_class_method :initialize_month_label
157
37
  end
158
38
  end
159
39
  end