zakuro 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -13
- data/VERSION +1 -1
- data/doc/dropped_date.md +93 -0
- data/doc/error.md +45 -0
- data/doc/operation/csv/month.csv +100 -79
- data/doc/operation/operation.xlsx +0 -0
- data/lib/zakuro/calculation/base/day.rb +52 -0
- data/lib/zakuro/calculation/base/gengou.rb +5 -5
- data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
- data/lib/zakuro/calculation/base/operated_year.rb +26 -24
- data/lib/zakuro/calculation/base/year.rb +7 -7
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
- data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +38 -29
- data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
- data/lib/zakuro/calculation/era/version/version.rb +12 -10
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
- data/lib/zakuro/calculation/monthly/const.rb +18 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
- data/lib/zakuro/calculation/monthly/month.rb +17 -17
- data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
- data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
- data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
- data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
- data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
- data/lib/zakuro/calculation/range/abstract_full_range.rb +40 -25
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +111 -109
- data/lib/zakuro/calculation/range/dated_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/dated_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/named_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
- data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
- data/lib/zakuro/calculation/summary/internal/month.rb +32 -11
- data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
- data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
- data/lib/zakuro/calculation/summary/japan/range.rb +145 -118
- data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +57 -50
- data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
- data/lib/zakuro/calculation/summary/western/range.rb +95 -92
- data/lib/zakuro/calculation/summary/western/single.rb +78 -76
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -119
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +63 -56
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/calculation/type/optional.rb +46 -0
- data/lib/zakuro/condition.rb +142 -92
- data/lib/zakuro/context/context.rb +44 -0
- data/lib/zakuro/context/option.rb +119 -0
- data/lib/zakuro/context/version_class_resolver.rb +112 -0
- data/lib/zakuro/era/japan/calendar.rb +35 -33
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +8 -4
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
- data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -34
- data/lib/zakuro/era/japan/gengou/resource/type.rb +45 -37
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
- data/lib/zakuro/era/japan/gengou.rb +28 -26
- data/lib/zakuro/era/japan/version.rb +18 -16
- data/lib/zakuro/era/western/calendar.rb +104 -88
- data/lib/zakuro/exception/case/pattern.rb +39 -3
- data/lib/zakuro/exception/case/preset.rb +2 -2
- data/lib/zakuro/exception/exception.rb +17 -15
- data/lib/zakuro/exception/zakuro_error.rb +19 -1
- data/lib/zakuro/gateway/locale/date.rb +2 -2
- data/lib/zakuro/gateway/locale/range.rb +3 -3
- data/lib/zakuro/gateway/range.rb +3 -3
- data/lib/zakuro/gateway/single.rb +14 -3
- data/lib/zakuro/merchant.rb +79 -9
- data/lib/zakuro/operation/month/parser.rb +252 -249
- data/lib/zakuro/operation/month/type.rb +17 -8
- data/lib/zakuro/operation/month/validator.rb +148 -144
- data/lib/zakuro/operation/operation.rb +38 -36
- data/lib/zakuro/operation/yaml/month.yaml +955 -281
- data/lib/zakuro/output/response.rb +107 -141
- data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
- data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
- data/lib/zakuro/result/data/single_day.rb +9 -1
- data/lib/zakuro/result/operation/month/annotation.rb +2 -2
- data/lib/zakuro/result/operation/month/history.rb +2 -2
- data/lib/zakuro/result/operation/month.rb +31 -0
- data/lib/zakuro/result/operation.rb +39 -0
- data/lib/zakuro/result/result.rb +3 -3
- data/lib/zakuro/tools/stringifier.rb +67 -42
- data/lib/zakuro/tools/typeconv.rb +17 -15
- data/lib/zakuro/tools/typeof.rb +15 -13
- data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
- data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
- data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
- data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
- data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
- data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/senmyou/const/remainder.rb +7 -1
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
- data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
- data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
- metadata +27 -7
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
- data/lib/zakuro/result/operation/month/bundle.rb +0 -36
- data/lib/zakuro/result/operation/operation.rb +0 -44
- data/lib/zakuro/version/context.rb +0 -44
- data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -1,218 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../operation/operation'
|
4
|
-
require_relative '../monthly/month'
|
5
|
-
|
6
|
-
# :nodoc:
|
7
|
-
module Zakuro
|
8
|
-
# :nodoc:
|
9
|
-
module Calculation
|
10
|
-
# :nodoc:
|
11
|
-
module Range
|
12
|
-
#
|
13
|
-
# OperatedSolarTerm 運用時二十四節気
|
14
|
-
#
|
15
|
-
class OperatedSolarTerms
|
16
|
-
# @return [Array<Year>] 完全範囲(年データ)
|
17
|
-
attr_reader :years
|
18
|
-
# @return [Hash<String, SolarTerm>] 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
|
19
|
-
#
|
20
|
-
# * 移動元の二十四節気:無効な大余小余あり(削除対象)
|
21
|
-
# * 移動先の二十四節気:移動元からの二十四節気(追加対象)
|
22
|
-
#
|
23
|
-
attr_reader :directions
|
24
|
-
# @return [Context] 暦コンテキスト
|
25
|
-
attr_reader :context
|
26
|
-
|
27
|
-
#
|
28
|
-
# 初期化
|
29
|
-
#
|
30
|
-
# @param [Context] context 暦コンテキスト
|
31
|
-
# @param [Array<Year>] years 完全範囲(年データ)
|
32
|
-
#
|
33
|
-
def initialize(context:, years: [])
|
34
|
-
@context = context
|
35
|
-
@years = years
|
36
|
-
@directions = {}
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# データ生成する
|
41
|
-
#
|
42
|
-
# @return [<Type>] <description>
|
43
|
-
#
|
44
|
-
def create
|
45
|
-
@directions = create_directions
|
46
|
-
end
|
47
|
-
|
48
|
-
#
|
49
|
-
# 二十四節気を取得する
|
50
|
-
#
|
51
|
-
# @param [Western::Calendar] western_date 月初日の西暦日
|
52
|
-
#
|
53
|
-
# @return [True] 対象あり
|
54
|
-
# @return [False] 対象なし
|
55
|
-
# @return [SolarTerm] 二十四節気
|
56
|
-
#
|
57
|
-
def get(western_date: Western::Calendar.new)
|
58
|
-
context = current_context(western_date: western_date)
|
59
|
-
|
60
|
-
solar_term_class = context.resolver.solar_term
|
61
|
-
solar_term = @directions.fetch(western_date.format, solar_term_class.new)
|
62
|
-
|
63
|
-
# 合致しない場合
|
64
|
-
return false, solar_term_class.new if solar_term.empty?
|
65
|
-
|
66
|
-
# 合致した上で、二十四節気が移動元(削除対象)の場合
|
67
|
-
# 合致した上で、二十四節気が移動先(追加対象)の場合
|
68
|
-
[true, solar_term]
|
69
|
-
end
|
70
|
-
|
71
|
-
# :reek:TooManyStatements { max_statements: 6 }
|
72
|
-
|
73
|
-
#
|
74
|
-
# 年内の全ての月の移動方向を作成する
|
75
|
-
#
|
76
|
-
# @param [Context] context 暦コンテキスト
|
77
|
-
# @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
|
78
|
-
# @param [Array<Month>] months 年内の全ての月
|
79
|
-
#
|
80
|
-
def self.create_directions_with_months(context:, directions: {}, months: [])
|
81
|
-
months.each do |month|
|
82
|
-
history = Operation.specify_history(western_date: month.western_date)
|
83
|
-
|
84
|
-
next if history.invalid?
|
85
|
-
|
86
|
-
direction = history.diffs.solar_term
|
87
|
-
|
88
|
-
next if direction.invalid?
|
89
|
-
|
90
|
-
OperatedSolarTerms.create_directions_each_month(
|
91
|
-
context: context, directions: directions, direction: direction, month: month
|
92
|
-
)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# :reek:LongParameterList {max_params: 4}
|
97
|
-
|
98
|
-
#
|
99
|
-
# 月毎の移動方向を作成する
|
100
|
-
#
|
101
|
-
# @param [Context] context 暦コンテキスト
|
102
|
-
# @param [Month] 月
|
103
|
-
# @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
|
104
|
-
# @param [Operation::SolarTerm::Diretion] 二十四節気(移動)
|
105
|
-
#
|
106
|
-
def self.create_directions_each_month(context:, month:, directions: {},
|
107
|
-
direction: Operation::SolarTerm::Diretion.new)
|
108
|
-
|
109
|
-
month.solar_terms.each do |solar_term|
|
110
|
-
OperatedSolarTerms.push_source(context: context, directions: directions,
|
111
|
-
direction: direction, solar_term: solar_term)
|
112
|
-
end
|
113
|
-
OperatedSolarTerms.push_destination(context: context, directions: directions,
|
114
|
-
destination: direction.destination)
|
115
|
-
end
|
116
|
-
|
117
|
-
# :reek:LongParameterList {max_params: 4}
|
118
|
-
|
119
|
-
#
|
120
|
-
# 移動先に有効な二十四節気(差し替える二十四節気)を指定する
|
121
|
-
#
|
122
|
-
# @param [Context] context 暦コンテキスト
|
123
|
-
# @param [SolarTerm] solar_term 二十四節気(計算値)
|
124
|
-
# @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
|
125
|
-
# @param [Operation::SolarTerm::Direction] source 二十四節気(移動)
|
126
|
-
#
|
127
|
-
def self.push_source(context:, solar_term:, directions: {},
|
128
|
-
direction: Operation::SolarTerm::Direction.new)
|
129
|
-
source = direction.source
|
130
|
-
|
131
|
-
return if source.invalid?
|
132
|
-
|
133
|
-
return unless source.index == solar_term.index
|
134
|
-
|
135
|
-
# 移動先に移動元の二十四節気を指定する
|
136
|
-
directions[source.to.format] = OperatedSolarTerms.created_source(
|
137
|
-
context: context, direction: direction, solar_term: solar_term
|
138
|
-
)
|
139
|
-
end
|
140
|
-
|
141
|
-
#
|
142
|
-
# 移動先に有効な二十四節気(差し替える二十四節気)を生成する
|
143
|
-
#
|
144
|
-
# @param [Context] context 暦コンテキスト
|
145
|
-
# @param [SolarTerm] solar_term 二十四節気(計算値)
|
146
|
-
# @param [Operation::SolarTerm::Direction] source 二十四節気(移動)
|
147
|
-
#
|
148
|
-
# @return [SolarTerm] 二十四節気(運用値)
|
149
|
-
#
|
150
|
-
def self.created_source(context:, solar_term:,
|
151
|
-
direction: Operation::SolarTerm::Direction.new)
|
152
|
-
operated_solar_term = solar_term.clone
|
153
|
-
remainder_class_name = context.resolver.remainder
|
154
|
-
|
155
|
-
unless direction.invalid_days?
|
156
|
-
# 二十四節気の大余をずらす
|
157
|
-
operated_solar_term.remainder.add!(
|
158
|
-
remainder_class_name.new(day: direction.days, minute: 0, second: 0)
|
159
|
-
)
|
160
|
-
end
|
161
|
-
|
162
|
-
operated_solar_term
|
163
|
-
end
|
164
|
-
|
165
|
-
#
|
166
|
-
# 移動元に無効な二十四節気(連番のみ指定)を指定する
|
167
|
-
#
|
168
|
-
# @param [Context] context 暦コンテキスト
|
169
|
-
# @param [Hash<String, SolarTerm>] directions 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
|
170
|
-
# @param [Operation::SolarTerm::Destination] destination 二十四節気(移動先)
|
171
|
-
#
|
172
|
-
def self.push_destination(context:, directions: {},
|
173
|
-
destination: Operation::SolarTerm::Destination.new)
|
174
|
-
return if destination.invalid?
|
175
|
-
|
176
|
-
solar_term_class = context.resolver.solar_term
|
177
|
-
directions[destination.from.format] = solar_term_class.new(
|
178
|
-
index: destination.index
|
179
|
-
)
|
180
|
-
end
|
181
|
-
|
182
|
-
private
|
183
|
-
|
184
|
-
#
|
185
|
-
# 日付に対応する暦コンテキストを取得する
|
186
|
-
#
|
187
|
-
# @param [Western::Calendar] western_date 西暦日
|
188
|
-
#
|
189
|
-
# @return [Context] 暦コンテキスト
|
190
|
-
#
|
191
|
-
def current_context(western_date: Western::Calendar.new)
|
192
|
-
@years.each do |year|
|
193
|
-
return year.context if western_date >= year.new_year_date
|
194
|
-
end
|
195
|
-
|
196
|
-
Context.new
|
197
|
-
end
|
198
|
-
|
199
|
-
#
|
200
|
-
# 二十四節気の移動元/移動先を生成する
|
201
|
-
#
|
202
|
-
# @return [Hash<String, SolarTerm>] 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
|
203
|
-
#
|
204
|
-
def create_directions
|
205
|
-
directions = {}
|
206
|
-
|
207
|
-
years.each do |year|
|
208
|
-
OperatedSolarTerms.create_directions_with_months(
|
209
|
-
context: year.context, directions: directions, months: year.months
|
210
|
-
)
|
211
|
-
end
|
212
|
-
|
213
|
-
directions
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative './history'
|
4
|
-
|
5
|
-
# :nodoc:
|
6
|
-
module Zakuro
|
7
|
-
#
|
8
|
-
# Result 演算結果
|
9
|
-
#
|
10
|
-
module Result
|
11
|
-
#
|
12
|
-
# 運用情報
|
13
|
-
#
|
14
|
-
module Operation
|
15
|
-
#
|
16
|
-
# Month 運用情報(月)
|
17
|
-
#
|
18
|
-
module Month
|
19
|
-
#
|
20
|
-
# Bundle 月履歴集約情報
|
21
|
-
#
|
22
|
-
class Bundle
|
23
|
-
# @return [History] 月別履歴情報(当月)
|
24
|
-
attr_reader :current
|
25
|
-
# @return [History] 月別履歴情報(影響を与えた月)
|
26
|
-
attr_reader :parent
|
27
|
-
|
28
|
-
def initialize(current: History.new, parent: History.new)
|
29
|
-
@current = current
|
30
|
-
@parent = parent
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../data/single_day'
|
4
|
-
|
5
|
-
require_relative './month/bundle'
|
6
|
-
|
7
|
-
# :nodoc:
|
8
|
-
module Zakuro
|
9
|
-
#
|
10
|
-
# Result 演算結果
|
11
|
-
#
|
12
|
-
module Result
|
13
|
-
#
|
14
|
-
# 運用情報
|
15
|
-
#
|
16
|
-
module Operation
|
17
|
-
#
|
18
|
-
# Bundle 運用情報
|
19
|
-
#
|
20
|
-
class Bundle
|
21
|
-
# @return [True] 運用あり
|
22
|
-
# @return [False] 運用なし
|
23
|
-
attr_reader :operated
|
24
|
-
# @return [Month::Bundle] 月別履歴情報
|
25
|
-
attr_reader :month
|
26
|
-
# @return [Data::SingleDay] 計算値
|
27
|
-
attr_reader :original
|
28
|
-
|
29
|
-
#
|
30
|
-
# 初期化
|
31
|
-
#
|
32
|
-
# @param [True, False] operated 運用有無
|
33
|
-
# @param [Month::Bundle] month 月別履歴情報
|
34
|
-
# @param [Data::SingleDay] original 計算値
|
35
|
-
#
|
36
|
-
def initialize(operated:, month:, original:)
|
37
|
-
@operated = operated
|
38
|
-
@month = month
|
39
|
-
@original = original
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative './version_class_resolver'
|
4
|
-
|
5
|
-
# :nodoc:
|
6
|
-
module Zakuro
|
7
|
-
#
|
8
|
-
# Context 暦コンテキスト
|
9
|
-
#
|
10
|
-
class Context
|
11
|
-
# @return [String] 暦名
|
12
|
-
attr_reader :version_name
|
13
|
-
# @return [VersionClassResolver] 暦リゾルバー
|
14
|
-
attr_reader :resolver
|
15
|
-
|
16
|
-
# @return [Array<String>] 暦名
|
17
|
-
VERSION_NAMES = %w[Genka Gihou Daien Senmyou Joukyou Kansei Tenpou Gregorio].freeze
|
18
|
-
|
19
|
-
#
|
20
|
-
# 初期化
|
21
|
-
#
|
22
|
-
# @param [String] version_name 暦名
|
23
|
-
#
|
24
|
-
def initialize(version_name: '')
|
25
|
-
@version_name = version_name
|
26
|
-
|
27
|
-
if !invalid? && !VERSION_NAMES.include?(version_name)
|
28
|
-
raise ArgumentError.new, 'invalid version'
|
29
|
-
end
|
30
|
-
|
31
|
-
@resolver = VersionClassResolver.new(version_name: version_name)
|
32
|
-
end
|
33
|
-
|
34
|
-
#
|
35
|
-
# 不正か
|
36
|
-
#
|
37
|
-
# @return [True] 不正
|
38
|
-
# @return [False] 不正なし
|
39
|
-
#
|
40
|
-
def invalid?
|
41
|
-
@version_name.empty?
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative './genka/cycle/remainder'
|
4
|
-
require_relative './genka/cycle/solar_term'
|
5
|
-
require_relative './genka/range/annual_range'
|
6
|
-
|
7
|
-
require_relative './gihou/cycle/remainder'
|
8
|
-
require_relative './gihou/cycle/solar_term'
|
9
|
-
require_relative './gihou/range/annual_range'
|
10
|
-
|
11
|
-
require_relative './daien/cycle/remainder'
|
12
|
-
require_relative './daien/cycle/solar_term'
|
13
|
-
require_relative './daien/range/annual_range'
|
14
|
-
|
15
|
-
require_relative './senmyou/cycle/remainder'
|
16
|
-
require_relative './senmyou/cycle/solar_term'
|
17
|
-
require_relative './senmyou/range/annual_range'
|
18
|
-
|
19
|
-
# :nodoc:
|
20
|
-
module Zakuro
|
21
|
-
#
|
22
|
-
# VersionClassResolver 暦リゾルバー
|
23
|
-
#
|
24
|
-
class VersionClassResolver
|
25
|
-
attr_reader :version_name
|
26
|
-
|
27
|
-
CLASSES = {
|
28
|
-
'remainder' => 'Zakuro::$VERSION::Cycle::Remainder',
|
29
|
-
'solar_term' => 'Zakuro::$VERSION::Cycle::SolarTerm',
|
30
|
-
'annual_range' => 'Zakuro::$VERSION::Range::AnnualRange'
|
31
|
-
}.freeze
|
32
|
-
|
33
|
-
def initialize(version_name:)
|
34
|
-
@version_name = version_name
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.get_class(version_name:, class_name:)
|
38
|
-
constant = CLASSES.fetch(class_name, '')
|
39
|
-
|
40
|
-
raise ArgumentError.new, 'invalid class name' if constant == ''
|
41
|
-
|
42
|
-
resolved_constant = constant.gsub('$VERSION', version_name)
|
43
|
-
|
44
|
-
Object.const_get(resolved_constant)
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# 大余小余(暦別)クラスを返す
|
49
|
-
#
|
50
|
-
# @return [Class] 大余小余(暦別)クラス
|
51
|
-
#
|
52
|
-
def remainder
|
53
|
-
VersionClassResolver.get_class(version_name: @version_name, class_name: 'remainder')
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
# 二十四節気クラスを返す
|
58
|
-
#
|
59
|
-
# @return [Class] 二十四節気クラス
|
60
|
-
#
|
61
|
-
def solar_term
|
62
|
-
VersionClassResolver.get_class(version_name: @version_name, class_name: 'solar_term')
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# 年間範囲クラスを返す
|
67
|
-
#
|
68
|
-
# @return [Class] 年間範囲クラス
|
69
|
-
#
|
70
|
-
def annual_range
|
71
|
-
VersionClassResolver.get_class(version_name: @version_name, class_name: 'annual_range')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|