zakuro 0.7.2 → 0.8.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 +3 -3
- data/VERSION +1 -1
- 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 +23 -21
- data/lib/zakuro/calculation/base/year.rb +3 -3
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +50 -44
- 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 +39 -37
- data/lib/zakuro/calculation/monthly/month.rb +15 -15
- data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
- data/lib/zakuro/calculation/monthly/operated_month.rb +36 -85
- data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
- data/lib/zakuro/calculation/range/abstract_full_range.rb +34 -21
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +109 -107
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- 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 +5 -5
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
- data/lib/zakuro/calculation/summary/internal/day.rb +21 -19
- data/lib/zakuro/calculation/summary/internal/month.rb +25 -12
- data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
- data/lib/zakuro/calculation/summary/internal/option.rb +66 -50
- data/lib/zakuro/calculation/summary/japan/range.rb +145 -124
- data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +54 -52
- 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 -124
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +60 -58
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/condition.rb +121 -111
- data/lib/zakuro/context/context.rb +1 -1
- data/lib/zakuro/context/option.rb +31 -29
- data/lib/zakuro/context/version_class_resolver.rb +26 -24
- data/lib/zakuro/era/japan/calendar.rb +35 -33
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +4 -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 -36
- data/lib/zakuro/era/japan/gengou/resource/type.rb +39 -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 +102 -90
- data/lib/zakuro/exception/case/preset.rb +2 -2
- data/lib/zakuro/exception/exception.rb +15 -13
- data/lib/zakuro/exception/zakuro_error.rb +1 -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 +1 -1
- data/lib/zakuro/gateway/single.rb +13 -2
- data/lib/zakuro/merchant.rb +1 -1
- data/lib/zakuro/operation/month/parser.rb +252 -251
- 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/output/response.rb +112 -113
- 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 +66 -64
- data/lib/zakuro/tools/typeconv.rb +17 -15
- data/lib/zakuro/tools/typeof.rb +15 -13
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
- data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -39
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -49
- 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 +2 -2
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
- 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/monthly/lunar_phase.rb +9 -9
- data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -39
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -49
- 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/monthly/lunar_phase.rb +10 -10
- data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -38
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -36
- 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 +12 -9
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
- data/lib/zakuro/result/operation/bundle.rb +0 -44
- data/lib/zakuro/result/operation/month/bundle.rb +0 -36
@@ -15,201 +15,203 @@ module Zakuro
|
|
15
15
|
# TypeParser 型ごと変換
|
16
16
|
#
|
17
17
|
module TypeParser
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
str
|
28
|
-
|
29
|
-
|
30
|
-
def self.text(str:)
|
31
|
-
return '' if invalid?(str: str)
|
32
|
-
|
33
|
-
str
|
34
|
-
end
|
18
|
+
class << self
|
19
|
+
#
|
20
|
+
# 無効値かを判定する
|
21
|
+
#
|
22
|
+
# @param [String] str 文字列
|
23
|
+
#
|
24
|
+
# @return [True] 無効値
|
25
|
+
# @return [False] 有効値
|
26
|
+
#
|
27
|
+
def invalid?(str:)
|
28
|
+
str == '-'
|
29
|
+
end
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
# @param [String] str 文字列
|
40
|
-
#
|
41
|
-
# @return [True] 有効
|
42
|
-
# @return [False] 無効
|
43
|
-
#
|
44
|
-
def self.modified?(str:)
|
45
|
-
str == 'true'
|
46
|
-
end
|
31
|
+
def text(str:)
|
32
|
+
return '' if invalid?(str: str)
|
47
33
|
|
48
|
-
|
49
|
-
|
50
|
-
#
|
51
|
-
# @param [String] str 文字列
|
52
|
-
#
|
53
|
-
# @return [Integer] 月
|
54
|
-
#
|
55
|
-
def self.month_number(str:)
|
56
|
-
return -1 if invalid?(str: str)
|
57
|
-
|
58
|
-
str.to_i
|
59
|
-
end
|
34
|
+
str
|
35
|
+
end
|
60
36
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
37
|
+
#
|
38
|
+
# 有効行を変換する
|
39
|
+
#
|
40
|
+
# @param [String] str 文字列
|
41
|
+
#
|
42
|
+
# @return [True] 有効
|
43
|
+
# @return [False] 無効
|
44
|
+
#
|
45
|
+
def modified?(str:)
|
46
|
+
str == 'true'
|
47
|
+
end
|
72
48
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
49
|
+
#
|
50
|
+
# 月を変換する
|
51
|
+
#
|
52
|
+
# @param [String] str 文字列
|
53
|
+
#
|
54
|
+
# @return [Integer] 月
|
55
|
+
#
|
56
|
+
def month_number(str:)
|
57
|
+
return -1 if invalid?(str: str)
|
58
|
+
|
59
|
+
str.to_i
|
60
|
+
end
|
82
61
|
|
83
|
-
|
84
|
-
|
62
|
+
#
|
63
|
+
# 閏有無を変換する
|
64
|
+
#
|
65
|
+
# @param [String] str 文字列
|
66
|
+
#
|
67
|
+
# @return [True] 閏あり
|
68
|
+
# @return [True] 閏なし/閏設定なし
|
69
|
+
#
|
70
|
+
def month_leaped(str:)
|
71
|
+
str == 'true'
|
72
|
+
end
|
85
73
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
74
|
+
#
|
75
|
+
# 西暦日を変換する
|
76
|
+
#
|
77
|
+
# @param [String] str 文字列
|
78
|
+
#
|
79
|
+
# @return [Western::Calendar] 西暦日
|
80
|
+
#
|
81
|
+
def western_date(str:)
|
82
|
+
return Western::Calendar.new if invalid?(str: str)
|
83
|
+
|
84
|
+
Western::Calendar.parse(text: str)
|
85
|
+
end
|
95
86
|
|
96
|
-
|
97
|
-
|
87
|
+
#
|
88
|
+
# 日(差分)を変換する
|
89
|
+
#
|
90
|
+
# @param [String] str 文字列
|
91
|
+
#
|
92
|
+
# @return [Integer] 日(差分)
|
93
|
+
#
|
94
|
+
def days(str:)
|
95
|
+
return INVALID_DAY_VALUE if invalid?(str: str)
|
96
|
+
|
97
|
+
str.to_i
|
98
|
+
end
|
98
99
|
|
99
|
-
|
100
|
-
|
100
|
+
def solar_term_index(str:)
|
101
|
+
return -1 if invalid?(str: str)
|
101
102
|
|
102
|
-
|
103
|
-
|
103
|
+
str.to_i
|
104
|
+
end
|
105
|
+
end
|
104
106
|
end
|
105
107
|
|
106
108
|
#
|
107
109
|
# MonthParser 月情報解析(yaml)
|
108
110
|
#
|
109
111
|
module MonthParser
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
112
|
+
class << self
|
113
|
+
#
|
114
|
+
# 実行する
|
115
|
+
#
|
116
|
+
# @return [Array<MonthHistory>] 変更履歴
|
117
|
+
#
|
118
|
+
# @raise [ArgumentError] 引数エラー
|
119
|
+
#
|
120
|
+
def run(filepath:)
|
121
|
+
hash = YAML.load_file(filepath)
|
122
|
+
|
123
|
+
failed = Validator.run(yaml_hash: hash)
|
124
|
+
|
125
|
+
raise ArgumentError, failed.join("\n") unless failed.empty?
|
126
|
+
|
127
|
+
load(yaml_hash: hash)
|
128
|
+
end
|
126
129
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
130
|
+
#
|
131
|
+
# 設定ファイルを読み込む
|
132
|
+
#
|
133
|
+
# @param [Hash] yaml_hash 設定ファイルテキスト
|
134
|
+
#
|
135
|
+
# @return [Array<MonthHistory>] 変更履歴
|
136
|
+
#
|
137
|
+
def load(yaml_hash: {})
|
138
|
+
histories = create_histories(yaml_hash: yaml_hash)
|
136
139
|
|
137
|
-
|
138
|
-
|
140
|
+
annotation_parser = AnnotationParser.new(yaml_hash: yaml_hash)
|
141
|
+
annotation_parser.create
|
139
142
|
|
140
|
-
|
141
|
-
|
143
|
+
add_annotations(histories: histories, annotation_parser: annotation_parser)
|
144
|
+
end
|
142
145
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
yaml_hash
|
153
|
-
|
146
|
+
private
|
147
|
+
|
148
|
+
#
|
149
|
+
# 変更履歴を読み込む
|
150
|
+
#
|
151
|
+
# @param [Hash] yaml_hash 設定ファイルテキスト
|
152
|
+
#
|
153
|
+
# @return [Array<MonthHistory>] 変更履歴
|
154
|
+
#
|
155
|
+
def create_histories(yaml_hash: {})
|
156
|
+
result = []
|
157
|
+
yaml_hash.each do |month|
|
158
|
+
next unless Operation::TypeParser.modified?(str: month['modified'])
|
159
|
+
|
160
|
+
result.push(
|
161
|
+
create_history(yaml_hash: month)
|
162
|
+
)
|
163
|
+
end
|
164
|
+
result
|
165
|
+
end
|
154
166
|
|
155
|
-
|
156
|
-
|
157
|
-
|
167
|
+
def create_history(yaml_hash: {})
|
168
|
+
diffs = MonthDiffsParser.create(yaml_hash: yaml_hash['diffs'])
|
169
|
+
|
170
|
+
western_date = Operation::TypeParser.western_date(str: yaml_hash['western_date'])
|
171
|
+
reference = Reference.new(page: yaml_hash['page'].to_i, number: yaml_hash['number'].to_i,
|
172
|
+
japan_date: yaml_hash['japan_date'])
|
173
|
+
MonthHistory.new(id: yaml_hash['id'],
|
174
|
+
parent_id: Operation::TypeParser.text(str: yaml_hash['parent_id']),
|
175
|
+
reference: reference,
|
176
|
+
western_date: western_date,
|
177
|
+
diffs: diffs)
|
158
178
|
end
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
reference: reference,
|
172
|
-
western_date: western_date,
|
173
|
-
diffs: diffs)
|
174
|
-
end
|
175
|
-
private_class_method :create_history
|
176
|
-
|
177
|
-
def self.add_annotations(annotation_parser:, histories: [])
|
178
|
-
result = []
|
179
|
-
histories.each do |history|
|
180
|
-
id = history.id
|
181
|
-
result.push(
|
182
|
-
MonthHistory.new(
|
183
|
-
id: id, parent_id: history.parent_id, reference: history.reference,
|
184
|
-
western_date: history.western_date,
|
185
|
-
annotations: annotation_parser.specify(id: id),
|
186
|
-
diffs: history.diffs
|
179
|
+
|
180
|
+
def add_annotations(annotation_parser:, histories: [])
|
181
|
+
result = []
|
182
|
+
histories.each do |history|
|
183
|
+
id = history.id
|
184
|
+
result.push(
|
185
|
+
MonthHistory.new(
|
186
|
+
id: id, parent_id: history.parent_id, reference: history.reference,
|
187
|
+
western_date: history.western_date,
|
188
|
+
annotations: annotation_parser.specify(id: id),
|
189
|
+
diffs: history.diffs
|
190
|
+
)
|
187
191
|
)
|
188
|
-
|
189
|
-
end
|
192
|
+
end
|
190
193
|
|
191
|
-
|
192
|
-
end
|
193
|
-
private_class_method :add_annotations
|
194
|
-
|
195
|
-
def self.create_history_annnotations(history:, annotations: {}, relations: {})
|
196
|
-
history_id = history.id
|
197
|
-
history_annotations = []
|
198
|
-
[history_id, relations.fetch(history_id, '')].each do |id|
|
199
|
-
add_annotation(history_annotations: history_annotations,
|
200
|
-
annotations: annotations, id: id)
|
194
|
+
result
|
201
195
|
end
|
202
196
|
|
203
|
-
|
204
|
-
|
197
|
+
def create_history_annnotations(history:, annotations: {}, relations: {})
|
198
|
+
history_id = history.id
|
199
|
+
history_annotations = []
|
200
|
+
[history_id, relations.fetch(history_id, '')].each do |id|
|
201
|
+
add_annotation(history_annotations: history_annotations,
|
202
|
+
annotations: annotations, id: id)
|
203
|
+
end
|
205
204
|
|
206
|
-
|
207
|
-
|
208
|
-
return if annotation.invalid?
|
205
|
+
history_annotations
|
206
|
+
end
|
209
207
|
|
210
|
-
history_annotations
|
208
|
+
def add_annotation(history_annotations: [], annotations: {}, id: '')
|
209
|
+
annotation = annotations.fetch(id, Annotation.new)
|
210
|
+
return if annotation.invalid?
|
211
|
+
|
212
|
+
history_annotations.push(annotation)
|
213
|
+
end
|
211
214
|
end
|
212
|
-
private_class_method :add_annotation
|
213
215
|
end
|
214
216
|
|
215
217
|
#
|
@@ -238,31 +240,33 @@ module Zakuro
|
|
238
240
|
def create
|
239
241
|
@yaml_hash.each do |month|
|
240
242
|
AnnotationParser.resolve_history(
|
241
|
-
hash: month, annotations:
|
243
|
+
hash: month, annotations: annotations, relations: relations
|
242
244
|
)
|
243
245
|
end
|
244
246
|
end
|
245
247
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
id
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
248
|
+
class << self
|
249
|
+
#
|
250
|
+
# 月別履歴情報から注釈情報を取り出す
|
251
|
+
#
|
252
|
+
# @param [<Type>] hash 月別履歴情報yaml
|
253
|
+
# @param [Hash<String, Annotation>] annotations 注釈
|
254
|
+
# @param [Hash<String, String>] relations 関連注釈の対応関係
|
255
|
+
#
|
256
|
+
def resolve_history(hash: {}, annotations: {}, relations: {})
|
257
|
+
id = hash['id']
|
258
|
+
annotations[id] = Annotation.new(
|
259
|
+
id: id,
|
260
|
+
description: Operation::TypeParser.text(str: hash['description']),
|
261
|
+
note: Operation::TypeParser.text(str: hash['note'])
|
262
|
+
)
|
263
|
+
relation_id = hash['relation_id']
|
264
|
+
|
265
|
+
return if Operation::TypeParser.invalid?(str: relation_id)
|
266
|
+
|
267
|
+
relations[id] = relation_id
|
268
|
+
end
|
269
|
+
end
|
266
270
|
|
267
271
|
#
|
268
272
|
# 注釈を特定する
|
@@ -295,7 +299,7 @@ module Zakuro
|
|
295
299
|
end
|
296
300
|
|
297
301
|
def annotation(id: '')
|
298
|
-
|
302
|
+
annotations.fetch(id, Annotation.new)
|
299
303
|
end
|
300
304
|
end
|
301
305
|
|
@@ -303,73 +307,70 @@ module Zakuro
|
|
303
307
|
# MonthDiffsParser 月情報(差分)解析
|
304
308
|
#
|
305
309
|
module MonthDiffsParser
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
310
|
+
class << self
|
311
|
+
def create(yaml_hash: {})
|
312
|
+
Diffs.new(
|
313
|
+
month: create_month(yaml_hash: yaml_hash['month']),
|
314
|
+
solar_term: create_solar_term(yaml_hash: yaml_hash['solar_term']),
|
315
|
+
days: Operation::TypeParser.days(str: yaml_hash['days'])
|
316
|
+
)
|
317
|
+
end
|
313
318
|
|
314
|
-
|
315
|
-
SolarTerm::Direction.new(
|
316
|
-
source: create_source_solar_term(yaml_hash: yaml_hash['src']),
|
317
|
-
destination: create_destination_solar_term(yaml_hash: yaml_hash['dest']),
|
318
|
-
days: Operation::TypeParser.days(str: yaml_hash['days'])
|
319
|
-
)
|
320
|
-
end
|
321
|
-
private_class_method :create_solar_term
|
322
|
-
|
323
|
-
def self.create_source_solar_term(yaml_hash: {})
|
324
|
-
SolarTerm::Source.new(
|
325
|
-
index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
|
326
|
-
to: Operation::TypeParser.western_date(str: yaml_hash['to']),
|
327
|
-
zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
|
328
|
-
)
|
329
|
-
end
|
330
|
-
private_class_method :create_source_solar_term
|
331
|
-
|
332
|
-
def self.create_destination_solar_term(yaml_hash: {})
|
333
|
-
SolarTerm::Destination.new(
|
334
|
-
index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
|
335
|
-
from: Operation::TypeParser.western_date(str: yaml_hash['from']),
|
336
|
-
zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
|
337
|
-
)
|
338
|
-
end
|
339
|
-
private_class_method :create_destination_solar_term
|
340
|
-
|
341
|
-
def self.create_month(yaml_hash: {})
|
342
|
-
Month.new(
|
343
|
-
number: create_month_number(yaml_hash: yaml_hash['number']),
|
344
|
-
leaped: create_month_leaped(yaml_hash: yaml_hash['leaped']),
|
345
|
-
is_many_days: create_month_day(yaml_hash: yaml_hash['days'])
|
346
|
-
)
|
347
|
-
end
|
348
|
-
private_class_method :create_month
|
319
|
+
private
|
349
320
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
321
|
+
def create_solar_term(yaml_hash: {})
|
322
|
+
SolarTerm::Direction.new(
|
323
|
+
source: create_source_solar_term(yaml_hash: yaml_hash['src']),
|
324
|
+
destination: create_destination_solar_term(yaml_hash: yaml_hash['dest']),
|
325
|
+
days: Operation::TypeParser.days(str: yaml_hash['days'])
|
326
|
+
)
|
327
|
+
end
|
357
328
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
329
|
+
def create_source_solar_term(yaml_hash: {})
|
330
|
+
SolarTerm::Source.new(
|
331
|
+
index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
|
332
|
+
to: Operation::TypeParser.western_date(str: yaml_hash['to']),
|
333
|
+
zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
|
334
|
+
)
|
335
|
+
end
|
365
336
|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
337
|
+
def create_destination_solar_term(yaml_hash: {})
|
338
|
+
SolarTerm::Destination.new(
|
339
|
+
index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
|
340
|
+
from: Operation::TypeParser.western_date(str: yaml_hash['from']),
|
341
|
+
zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
|
342
|
+
)
|
343
|
+
end
|
344
|
+
|
345
|
+
def create_month(yaml_hash: {})
|
346
|
+
Month.new(
|
347
|
+
number: create_month_number(yaml_hash: yaml_hash['number']),
|
348
|
+
leaped: create_month_leaped(yaml_hash: yaml_hash['leaped']),
|
349
|
+
is_many_days: create_month_day(yaml_hash: yaml_hash['days'])
|
350
|
+
)
|
351
|
+
end
|
352
|
+
|
353
|
+
def create_month_number(yaml_hash: {})
|
354
|
+
Number.new(
|
355
|
+
src: Operation::TypeParser.month_number(str: yaml_hash['src']),
|
356
|
+
dest: Operation::TypeParser.month_number(str: yaml_hash['dest'])
|
357
|
+
)
|
358
|
+
end
|
359
|
+
|
360
|
+
def create_month_leaped(yaml_hash: {})
|
361
|
+
Leaped.new(
|
362
|
+
src: Operation::TypeParser.month_leaped(str: yaml_hash['src']),
|
363
|
+
dest: Operation::TypeParser.month_leaped(str: yaml_hash['dest'])
|
364
|
+
)
|
365
|
+
end
|
366
|
+
|
367
|
+
def create_month_day(yaml_hash: {})
|
368
|
+
Days.new(
|
369
|
+
src: yaml_hash['src'],
|
370
|
+
dest: yaml_hash['dest']
|
371
|
+
)
|
372
|
+
end
|
371
373
|
end
|
372
|
-
private_class_method :create_month_day
|
373
374
|
end
|
374
375
|
end
|
375
376
|
end
|
@@ -250,7 +250,7 @@ module Zakuro
|
|
250
250
|
# @return [False] 有効
|
251
251
|
#
|
252
252
|
def invalid_days?
|
253
|
-
|
253
|
+
days == INVALID_DAY_VALUE
|
254
254
|
end
|
255
255
|
|
256
256
|
#
|
@@ -260,7 +260,7 @@ module Zakuro
|
|
260
260
|
# @return [False] 有効
|
261
261
|
#
|
262
262
|
def invalid?
|
263
|
-
|
263
|
+
source.invalid? && destination.invalid?
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
@@ -295,7 +295,7 @@ module Zakuro
|
|
295
295
|
# @return [False] 有効
|
296
296
|
#
|
297
297
|
def invalid?
|
298
|
-
|
298
|
+
index == -1
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
@@ -330,7 +330,7 @@ module Zakuro
|
|
330
330
|
# @return [False] 有効
|
331
331
|
#
|
332
332
|
def invalid?
|
333
|
-
|
333
|
+
index == -1
|
334
334
|
end
|
335
335
|
end
|
336
336
|
end
|
@@ -339,7 +339,7 @@ module Zakuro
|
|
339
339
|
# Number 月
|
340
340
|
#
|
341
341
|
class Number
|
342
|
-
# @return [Integer]
|
342
|
+
# @return [Integer] 移動元
|
343
343
|
attr_reader :src
|
344
344
|
# @return [Integer] 移動先
|
345
345
|
attr_reader :dest
|
@@ -362,7 +362,7 @@ module Zakuro
|
|
362
362
|
# @return [False] 有効
|
363
363
|
#
|
364
364
|
def invalid?
|
365
|
-
|
365
|
+
src == -1 || dest == -1
|
366
366
|
end
|
367
367
|
|
368
368
|
#
|
@@ -381,7 +381,7 @@ module Zakuro
|
|
381
381
|
# @return [Integer] 間隔
|
382
382
|
#
|
383
383
|
def interval
|
384
|
-
|
384
|
+
src - dest
|
385
385
|
end
|
386
386
|
|
387
387
|
#
|
@@ -453,7 +453,7 @@ module Zakuro
|
|
453
453
|
# @return [False] 有効
|
454
454
|
#
|
455
455
|
def invalid?
|
456
|
-
|
456
|
+
!src && !dest
|
457
457
|
end
|
458
458
|
end
|
459
459
|
|
@@ -466,6 +466,15 @@ module Zakuro
|
|
466
466
|
# @return [String] 30日
|
467
467
|
BIG = '大'
|
468
468
|
|
469
|
+
# NOTE: 下記readerは不要とする
|
470
|
+
# * Number/Leaped とメソッド名を揃えている
|
471
|
+
# * 大小の真偽値が必要で、文字列ではない
|
472
|
+
#
|
473
|
+
# @return [String] 移動元
|
474
|
+
# attr_reader :src
|
475
|
+
# @return [String] 移動先
|
476
|
+
# attr_reader :dest
|
477
|
+
|
469
478
|
#
|
470
479
|
# 初期化
|
471
480
|
#
|