zakuro 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
- data/lib/zakuro/calculation/base/year.rb +107 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +484 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
- data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +169 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
- data/lib/zakuro/calculation/monthly/month.rb +187 -0
- data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
- data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
- data/lib/zakuro/calculation/range/full_range.rb +210 -0
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +105 -0
- data/lib/zakuro/calculation/range/operated_range.rb +144 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +78 -0
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +71 -0
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +117 -0
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +187 -0
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +136 -0
- data/lib/zakuro/calculation/summary/single.rb +129 -0
- data/lib/zakuro/calculation/type/old_float.rb +69 -0
- data/lib/zakuro/era/japan/reki.rb +1 -1
- data/lib/zakuro/merchant.rb +2 -2
- data/lib/zakuro/output/error.rb +7 -6
- data/lib/zakuro/output/logger.rb +50 -49
- data/lib/zakuro/output/response.rb +145 -144
- data/lib/zakuro/tools/typeof.rb +2 -2
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/abstract_version.rb +1 -1
- data/lib/zakuro/version/context.rb +23 -0
- data/lib/zakuro/version/daien/const/number.rb +55 -0
- data/lib/zakuro/version/daien/const/remainder.rb +53 -0
- data/lib/zakuro/version/daien/cycle/remainder.rb +59 -0
- data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/daien/daien.rb +36 -0
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
- data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
- data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
- data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
- data/lib/zakuro/version/gihou/const/number.rb +55 -0
- data/lib/zakuro/version/gihou/const/remainder.rb +54 -0
- data/lib/zakuro/version/gihou/cycle/remainder.rb +56 -0
- data/lib/zakuro/version/gihou/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/gihou/gihou.rb +23 -2
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +106 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +39 -0
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +250 -0
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/gihou/stella/lunar/location.rb +80 -0
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +75 -0
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/gihou/stella/solar/average.rb +97 -0
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +108 -0
- data/lib/zakuro/version/gihou/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/gihou/stella/solar/value.rb +36 -0
- data/lib/zakuro/version/senmyou/const/number.rb +51 -0
- data/lib/zakuro/version/senmyou/const/remainder.rb +47 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +56 -0
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +80 -195
- data/lib/zakuro/version/senmyou/range/annual_range.rb +25 -145
- data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +87 -0
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +67 -0
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +97 -0
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
- data/lib/zakuro/version/senmyou/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +39 -0
- data/lib/zakuro/version/version_class_resolver.rb +70 -0
- data/lib/zakuro/version_factory.rb +3 -3
- metadata +83 -28
- data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
- data/lib/zakuro/cycle/zodiac.rb +0 -103
- data/lib/zakuro/version/senmyou/base/era.rb +0 -83
- data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
- data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
- data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
- data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -148
- data/lib/zakuro/version/senmyou/base/year.rb +0 -104
- data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
- data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -119
- data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
- data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
- data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -196
- data/lib/zakuro/version/senmyou/range/full_range.rb +0 -194
- data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -126
- data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -181
- data/lib/zakuro/version/senmyou/range/western_date_allocation.rb +0 -68
- data/lib/zakuro/version/senmyou/range/year_boundary.rb +0 -138
- data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -102
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -169
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +0 -213
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -213
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
- data/lib/zakuro/version/senmyou/summary/single.rb +0 -125
- 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 '../../../
|
3
|
+
require_relative '../../../calculation/monthly/abstract_lunar_phase'
|
4
4
|
|
5
|
-
require_relative '../
|
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
|
-
# :
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
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
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
52
|
+
#
|
53
|
+
# 現在の定朔を取得する
|
54
|
+
#
|
55
|
+
# @return [Remainder] 定朔
|
56
|
+
#
|
57
|
+
def current_remainder
|
58
|
+
debug("@average_remainder.format: #{@average_remainder.format}")
|
155
59
|
|
156
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
84
|
+
# :reek:TooManyStatements { max_statements: 6 }
|
173
85
|
|
174
|
-
|
175
|
-
|
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
|
-
|
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 '../../../
|
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/
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|