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
@@ -1,194 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../base/multi_gengou_roller'
4
-
5
- require_relative '../../../era/western'
6
- require_relative './annual_range'
7
- require_relative './year_boundary'
8
- require_relative './western_date_allocation'
9
-
10
- require_relative '../base/year'
11
-
12
- # :nodoc:
13
- module Zakuro
14
- # :nodoc:
15
- module Senmyou
16
- # :reek:TooManyInstanceVariables { max_instance_variables: 5 }
17
-
18
- #
19
- # FullRange 完全範囲
20
- # ある日からある日の範囲を計算可能な年月範囲
21
- # * 前提として元号年はその元号の開始年から数える
22
- # * ある日の元号年を求める場合、その元号が含まれる最初の年まで遡る
23
- # * 元号は一つとは限らない。南北朝などで二つある場合は、古い方の元号から求める
24
- #
25
- # NOTE: 割り当てた元号は年初を基準にした元号年である
26
- # * 元旦を基準にした時の正しい元号を設定している
27
- # * 引き当てたい日付が元旦ではない場合、その月日に従い元号を再度求める
28
- # * この再計算が必要になるのは、元号が切り替わる年のみである
29
- #
30
- class FullRange
31
- # @return [Western::Calendar] 開始日
32
- attr_reader :start_date
33
- # @return [Western::Calendar] 終了日
34
- attr_reader :end_date
35
- # @return [MultiGengouRoller] 改元処理
36
- attr_reader :multi_gengou_roller
37
- # @return [Western::Calendar] 最過去の元旦
38
- attr_reader :new_year_date
39
- # @return [Integer] 西暦年
40
- attr_reader :western_year
41
-
42
- # @return [Logger] ロガー
43
- LOGGER = Logger.new(location: 'full_range')
44
-
45
- #
46
- # 初期化
47
- #
48
- # @param [Western::Calendar] start_date 開始日
49
- # @param [Western::Calendar] end_date 終了日
50
- #
51
- def initialize(start_date: Western::Calendar.new, end_date: Western::Calendar.new)
52
- @start_date = start_date
53
- @end_date = end_date
54
- return if invalid?
55
-
56
- @multi_gengou_roller = MultiGengouRoller.new(start_date: start_date, end_date: end_date)
57
- @new_year_date = @multi_gengou_roller.oldest_date.clone
58
- @western_year = @new_year_date.year
59
- end
60
-
61
- #
62
- # 無効か
63
- #
64
- # @return [True] 無効
65
- # @return [False] 有効
66
- #
67
- def invalid?
68
- @start_date.invalid?
69
- end
70
-
71
- #
72
- # 完全範囲を取得する
73
- #
74
- # @return [Array<Year>] 完全範囲
75
- #
76
- def get
77
- return [] if invalid?
78
-
79
- years = YearBoundary.get(annual_ranges: annual_ranges)
80
- years = update_gengou(years: years)
81
-
82
- WesternDateAllocation.update_first_day(years: years)
83
-
84
- years
85
- end
86
-
87
- # :reek:TooManyStatements { max_statements: 6 }
88
-
89
- #
90
- # 完全範囲内の年データを取得する
91
- #
92
- # @return [Array<Year>] 年データ(冬至基準)
93
- #
94
- def annual_ranges
95
- oldest_date = @new_year_date
96
- newest_date = @multi_gengou_roller.newest_date
97
-
98
- years = []
99
- ((oldest_date.year)..(newest_date.year + 2)).each do |year|
100
- years.push(
101
- AnnualRange.collect_annual_range_after_last_november_1st(
102
- western_year: year
103
- )
104
- )
105
- end
106
-
107
- years
108
- end
109
-
110
- # :reek:TooManyStatements { max_statements: 8 }
111
-
112
- #
113
- # 完全範囲内の年データの元号を開始年基準で更新する
114
- #
115
- # @param [Array<Year>] years 年データ(元旦基準)
116
- #
117
- # @return [Array<Year>] 元号更新済み年データ(元旦基準)
118
- #
119
- def update_gengou(years:)
120
- updated_years = []
121
-
122
- nearest_end_date = choise_nearest_end_date
123
-
124
- years.each do |year|
125
- next_year(years: updated_years, year: year)
126
-
127
- if @new_year_date > nearest_end_date
128
- @multi_gengou_roller.transfer
129
- nearest_end_date = choise_nearest_end_date
130
- end
131
- @multi_gengou_roller.next_year
132
- end
133
-
134
- updated_years
135
- end
136
-
137
- private
138
-
139
- #
140
- # 元号処理対象の年を進める
141
- #
142
- # @param [Array<Year>] years 元号処理済み年データ(元旦基準)
143
- # @param [Year] year 元号処理前の年(元旦基準)
144
- #
145
- def next_year(years:, year:)
146
- updated_year = update_year(year: year)
147
-
148
- years.push(updated_year)
149
-
150
- next_new_year_date(total_days: updated_year.total_days)
151
-
152
- nil
153
- end
154
-
155
- #
156
- # 年の元号を更新する
157
- #
158
- # @param [Year] year 元号処理前の年(元旦基準)
159
- #
160
- # @return [Year] 元号処理済の年(元旦基準)
161
- #
162
- def update_year(year:)
163
- multi_gengou = @multi_gengou_roller.multi_gengou.clone
164
-
165
- updated_year = Year.new(multi_gengou: multi_gengou, new_year_date: @new_year_date.clone,
166
- months: year.months)
167
- updated_year.commit
168
-
169
- updated_year
170
- end
171
-
172
- #
173
- # 次の年に進める
174
- #
175
- # @param [Integer] total_days 年の日数
176
- #
177
- def next_new_year_date(total_days:)
178
- @new_year_date += total_days
179
- @multi_gengou_roller.next(days: total_days)
180
-
181
- nil
182
- end
183
-
184
- #
185
- # 現在日からみて直近の未来に対する元号の切替前日を求める
186
- #
187
- # @return [Western::Calendar] 元号の切替前日
188
- #
189
- def choise_nearest_end_date
190
- @multi_gengou_roller.choise_nearest_end_date
191
- end
192
- end
193
- end
194
- end
@@ -1,126 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative './full_range'
4
- require_relative './operated_solar_terms'
5
- require_relative '../../../operation/operation'
6
- require_relative '../monthly/operated_month'
7
-
8
- # :nodoc:
9
- module Zakuro
10
- # :nodoc:
11
- module Senmyou
12
- #
13
- # OperatedRange 運用結果範囲
14
- #
15
- # 何らかの理由により、計算された暦とは異なる運用結果である場合、その結果に合わせて計算結果を上書きする
16
- class OperatedRange
17
- # @return [Array<Year>] 年データ(完全範囲)
18
- attr_reader :years
19
- # @return [OperatedSolarTerms] 運用時二十四節気
20
- attr_reader :operated_solar_terms
21
-
22
- #
23
- # 初期化
24
- #
25
- # @param [Array<Year>] years 年データ(完全範囲)
26
- #
27
- def initialize(years: [])
28
- @years = years
29
- @operated_solar_terms = OperatedSolarTerms.new(years: @years)
30
- @operated_solar_terms.create
31
- end
32
-
33
- #
34
- # 運用結果範囲を取得する
35
- #
36
- # @return [Array<Year>] 運用結果範囲
37
- #
38
- def get
39
- rewrite
40
- end
41
-
42
- #
43
- # 運用結果に書き換える
44
- #
45
- # @return [Array<Year>] 運用結果範囲
46
- #
47
- def rewrite
48
- operated_years = []
49
-
50
- years.each do |year|
51
- operated_year = OperatedRange.rewrite_year(
52
- year: year, operated_solar_terms: @operated_solar_terms
53
- )
54
- operated_years.push(operated_year)
55
- end
56
-
57
- operated_years
58
- end
59
-
60
- #
61
- # 年を書き換える
62
- #
63
- # @param [Year] year 年
64
- # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
65
- #
66
- # @return [Year] 年
67
- #
68
- def self.rewrite_year(year:, operated_solar_terms:)
69
- result = Year.new(multi_gengou: year.multi_gengou, new_year_date: year.new_year_date)
70
- year.months.each do |month|
71
- result.push(month: resolve_month(
72
- month: month, operated_solar_terms: operated_solar_terms
73
- ))
74
- end
75
-
76
- result.commit
77
-
78
- result
79
- end
80
-
81
- #
82
- # 履歴情報の有無に応じた月にする
83
- #
84
- # @param [Month] month 月
85
- # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
86
- #
87
- # @return [Month] 月
88
- #
89
- def self.resolve_month(month:, operated_solar_terms:)
90
- history = Operation.specify_history(western_date: month.western_date)
91
-
92
- return month if history.invalid?
93
-
94
- OperatedRange.rewrite_month(
95
- month: month, history: history, operated_solar_terms: operated_solar_terms
96
- )
97
- end
98
-
99
- #
100
- # 月を運用結果に書き換える
101
- #
102
- # @param [Month] month 月
103
- # @param [Operation::MonthHistory] history 変更履歴
104
- # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
105
- #
106
- # @return [Month] 月(運用結果)
107
- #
108
- def self.rewrite_month(month:, history:, operated_solar_terms:)
109
- return month unless month.western_date == history.western_date
110
-
111
- operated_month = OperatedMonth.new(
112
- month_label: month.month_label, first_day: month.first_day,
113
- solar_terms: month.solar_terms, history: history,
114
- operated_solar_terms: operated_solar_terms
115
- )
116
-
117
- operated_month.rewrite
118
-
119
- Month.new(
120
- month_label: operated_month.month_label, first_day: operated_month.first_day,
121
- solar_terms: operated_month.solar_terms
122
- )
123
- end
124
- end
125
- end
126
- end
@@ -1,181 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative './full_range'
4
- require_relative '../../../operation/operation'
5
- require_relative '../monthly/month'
6
-
7
- # TODO: solar_termの中はsrc/destだが、yamlはcalc/actual。統一したい。
8
-
9
- # :nodoc:
10
- module Zakuro
11
- # :nodoc:
12
- module Senmyou
13
- #
14
- # OperatedSolarTerm 運用時二十四節気
15
- #
16
- class OperatedSolarTerms
17
- # @return [Array<Year>] 完全範囲(年データ)
18
- attr_reader :years
19
- # @return [Hash<String, SolarTerm>] 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
20
- #
21
- # * 移動元の二十四節気:無効な大余小余あり(削除対象)
22
- # * 移動先の二十四節気:移動元からの二十四節気(追加対象)
23
- #
24
- attr_reader :directions
25
-
26
- #
27
- # 初期化
28
- #
29
- # @param [Array<Year>] years 完全範囲(年データ)
30
- #
31
- def initialize(years: [])
32
- @years = years
33
- @directions = {}
34
- end
35
-
36
- #
37
- # データ生成する
38
- #
39
- # @return [<Type>] <description>
40
- #
41
- def create
42
- @directions = create_directions
43
- end
44
-
45
- #
46
- # 二十四節気を取得する
47
- #
48
- # @param [Western::Calendar] western_date 月初日の西暦日
49
- #
50
- # @return [True] 対象あり
51
- # @return [False] 対象なし
52
- # @return [SolarTerm] 二十四節気
53
- #
54
- def get(western_date: Western::Calendar.new)
55
- solar_term = @directions.fetch(western_date.format, SolarTerm.new)
56
-
57
- # 合致しない場合
58
- return false, SolarTerm.new if solar_term.empty?
59
-
60
- # 合致した上で、二十四節気が移動元(削除対象)の場合
61
- # 合致した上で、二十四節気が移動先(追加対象)の場合
62
- [true, solar_term]
63
- end
64
-
65
- #
66
- # 二十四節気の移動元/移動先を生成する
67
- #
68
- # @return [Hash<String, SolarTerm>] 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
69
- #
70
- def create_directions
71
- directions = {}
72
-
73
- years.each do |year|
74
- OperatedSolarTerms.create_directions_with_months(
75
- directions: directions, months: year.months
76
- )
77
- end
78
-
79
- directions
80
- end
81
-
82
- # :reek:TooManyStatements { max_statements: 6 }
83
-
84
- #
85
- # 年内の全ての月の移動方向を作成する
86
- #
87
- # @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
88
- # @param [Array<Month>] months 年内の全ての月
89
- #
90
- def self.create_directions_with_months(directions: {}, months: [])
91
- months.each do |month|
92
- history = Operation.specify_history(western_date: month.western_date)
93
-
94
- next if history.invalid?
95
-
96
- direction = history.diffs.solar_term
97
-
98
- next if direction.invalid?
99
-
100
- OperatedSolarTerms.create_directions_each_month(
101
- directions: directions, direction: direction, month: month
102
- )
103
- end
104
- end
105
-
106
- #
107
- # 月毎の移動方向を作成する
108
- #
109
- # @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
110
- # @param [Operation::SolarTerm::Diretion] 二十四節気(移動)
111
- # @param [Month] 月
112
- #
113
- def self.create_directions_each_month(directions: {},
114
- direction: Operation::SolarTerm::Diretion.new,
115
- month: Month.new)
116
-
117
- month.solar_terms.each do |solar_term|
118
- OperatedSolarTerms.push_source(directions: directions, direction: direction,
119
- solar_term: solar_term)
120
- end
121
- OperatedSolarTerms.push_destination(directions: directions,
122
- destination: direction.destination)
123
- end
124
-
125
- #
126
- # 移動先に有効な二十四節気(差し替える二十四節気)を指定する
127
- #
128
- # @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
129
- # @param [Operation::SolarTerm::Direction] source 二十四節気(移動)
130
- # @param [SolarTerm] solar_term 二十四節気(計算値)
131
- #
132
- def self.push_source(directions: {}, direction: Operation::SolarTerm::Direction.new,
133
- solar_term: SolarTerm.new)
134
- source = direction.source
135
-
136
- return if source.invalid?
137
-
138
- return unless source.index == solar_term.index
139
-
140
- # 移動先に移動元の二十四節気を指定する
141
- directions[source.to.format] = OperatedSolarTerms.created_source(
142
- direction: direction, solar_term: solar_term
143
- )
144
- end
145
-
146
- #
147
- # 移動先に有効な二十四節気(差し替える二十四節気)を生成する
148
- #
149
- # @param [Operation::SolarTerm::Direction] source 二十四節気(移動)
150
- # @param [SolarTerm] solar_term 二十四節気(計算値)
151
- #
152
- # @return [SolarTerm] 二十四節気(運用値)
153
- #
154
- def self.created_source(direction: Operation::SolarTerm::Direction.new,
155
- solar_term: SolarTerm.new)
156
- operated_solar_term = solar_term.clone
157
-
158
- unless direction.invalid_days?
159
- # 二十四節気の大余をずらす
160
- operated_solar_term.remainder.add!(
161
- Remainder.new(day: direction.days, minute: 0, second: 0)
162
- )
163
- end
164
-
165
- operated_solar_term
166
- end
167
-
168
- #
169
- # 移動元に無効な二十四節気(連番のみ指定)を指定する
170
- #
171
- # @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
172
- # @param [Operation::SolarTerm::Destination] destination 二十四節気(移動先)
173
- #
174
- def self.push_destination(directions: {}, destination: Operation::SolarTerm::Destination.new)
175
- return if destination.invalid?
176
-
177
- directions[destination.from.format] = SolarTerm.new(index: destination.index)
178
- end
179
- end
180
- end
181
- end