zakuro 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/VERSION +1 -1
  4. data/lib/zakuro/calculation/base/gengou.rb +5 -5
  5. data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
  6. data/lib/zakuro/calculation/base/operated_year.rb +23 -21
  7. data/lib/zakuro/calculation/base/year.rb +3 -3
  8. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +50 -44
  9. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
  10. data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
  11. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +38 -29
  12. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
  13. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
  14. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
  15. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
  16. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
  17. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
  18. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
  19. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
  22. data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
  23. data/lib/zakuro/calculation/era/version/version.rb +12 -10
  24. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
  25. data/lib/zakuro/calculation/monthly/const.rb +18 -0
  26. data/lib/zakuro/calculation/monthly/initialized_month.rb +39 -37
  27. data/lib/zakuro/calculation/monthly/month.rb +15 -15
  28. data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
  29. data/lib/zakuro/calculation/monthly/operated_month.rb +36 -85
  30. data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
  31. data/lib/zakuro/calculation/range/abstract_full_range.rb +34 -21
  32. data/lib/zakuro/calculation/range/abstract_operation_range.rb +109 -107
  33. data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
  34. data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
  35. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
  36. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
  37. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
  38. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
  39. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
  40. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +5 -5
  41. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
  42. data/lib/zakuro/calculation/summary/internal/day.rb +21 -19
  43. data/lib/zakuro/calculation/summary/internal/month.rb +25 -12
  44. data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
  45. data/lib/zakuro/calculation/summary/internal/option.rb +66 -50
  46. data/lib/zakuro/calculation/summary/japan/range.rb +145 -124
  47. data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
  48. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +54 -52
  49. data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
  50. data/lib/zakuro/calculation/summary/western/range.rb +95 -92
  51. data/lib/zakuro/calculation/summary/western/single.rb +78 -76
  52. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -124
  53. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +60 -58
  54. data/lib/zakuro/calculation/type/old_float.rb +2 -2
  55. data/lib/zakuro/condition.rb +121 -111
  56. data/lib/zakuro/context/context.rb +1 -1
  57. data/lib/zakuro/context/option.rb +31 -29
  58. data/lib/zakuro/context/version_class_resolver.rb +26 -24
  59. data/lib/zakuro/era/japan/calendar.rb +35 -33
  60. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +4 -4
  61. data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
  62. data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
  63. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
  64. data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
  65. data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -36
  66. data/lib/zakuro/era/japan/gengou/resource/type.rb +39 -37
  67. data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
  68. data/lib/zakuro/era/japan/gengou.rb +28 -26
  69. data/lib/zakuro/era/japan/version.rb +18 -16
  70. data/lib/zakuro/era/western/calendar.rb +102 -90
  71. data/lib/zakuro/exception/case/preset.rb +2 -2
  72. data/lib/zakuro/exception/exception.rb +15 -13
  73. data/lib/zakuro/exception/zakuro_error.rb +1 -1
  74. data/lib/zakuro/gateway/locale/date.rb +2 -2
  75. data/lib/zakuro/gateway/locale/range.rb +3 -3
  76. data/lib/zakuro/gateway/range.rb +1 -1
  77. data/lib/zakuro/gateway/single.rb +13 -2
  78. data/lib/zakuro/merchant.rb +1 -1
  79. data/lib/zakuro/operation/month/parser.rb +252 -251
  80. data/lib/zakuro/operation/month/type.rb +17 -8
  81. data/lib/zakuro/operation/month/validator.rb +148 -144
  82. data/lib/zakuro/operation/operation.rb +38 -36
  83. data/lib/zakuro/output/response.rb +112 -113
  84. data/lib/zakuro/result/operation/month/annotation.rb +2 -2
  85. data/lib/zakuro/result/operation/month/history.rb +2 -2
  86. data/lib/zakuro/result/operation/month.rb +31 -0
  87. data/lib/zakuro/result/operation.rb +39 -0
  88. data/lib/zakuro/result/result.rb +3 -3
  89. data/lib/zakuro/tools/stringifier.rb +66 -64
  90. data/lib/zakuro/tools/typeconv.rb +17 -15
  91. data/lib/zakuro/tools/typeof.rb +15 -13
  92. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
  93. data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
  94. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -39
  95. data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
  96. data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -49
  97. data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
  98. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
  99. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
  100. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
  101. data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
  102. data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
  103. data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
  104. data/lib/zakuro/version/genka/cycle/remainder.rb +2 -2
  105. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
  106. data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
  107. data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
  108. data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
  109. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
  110. data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
  111. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -39
  112. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
  113. data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -49
  114. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
  115. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
  116. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
  117. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
  118. data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
  119. data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
  120. data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
  121. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
  122. data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
  123. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -38
  124. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
  125. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -36
  126. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
  127. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
  128. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
  129. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
  130. data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
  131. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
  132. data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
  133. metadata +12 -9
  134. data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
  135. data/lib/zakuro/result/operation/bundle.rb +0 -44
  136. 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
- # @param [String] str 文字列
22
- #
23
- # @return [True] 無効値
24
- # @return [False] 有効値
25
- #
26
- def self.invalid?(str:)
27
- str == '-'
28
- end
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
- # @param [String] str 文字列
65
- #
66
- # @return [True] 閏あり
67
- # @return [True] 閏なし/閏設定なし
68
- #
69
- def self.month_leaped(str:)
70
- str == 'true'
71
- end
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
- # @param [String] str 文字列
77
- #
78
- # @return [Western::Calendar] 西暦日
79
- #
80
- def self.western_date(str:)
81
- return Western::Calendar.new if invalid?(str: str)
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
- Western::Calendar.parse(text: str)
84
- end
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
- # @param [String] str 文字列
90
- #
91
- # @return [Integer] 日(差分)
92
- #
93
- def self.days(str:)
94
- return INVALID_DAY_VALUE if invalid?(str: str)
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
- str.to_i
97
- end
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
- def self.solar_term_index(str:)
100
- return -1 if invalid?(str: str)
100
+ def solar_term_index(str:)
101
+ return -1 if invalid?(str: str)
101
102
 
102
- str.to_i
103
- end
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
- # @return [Array<MonthHistory>] 変更履歴
114
- #
115
- # @raise [ArgumentError] 引数エラー
116
- #
117
- def self.run(filepath:)
118
- hash = YAML.load_file(filepath)
119
-
120
- failed = Validator.run(yaml_hash: hash)
121
-
122
- raise ArgumentError, failed.join("\n") unless failed.empty?
123
-
124
- load(yaml_hash: hash)
125
- end
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
- # @param [Hash] yaml_hash 設定ファイルテキスト
131
- #
132
- # @return [Array<MonthHistory>] 変更履歴
133
- #
134
- def self.load(yaml_hash: {})
135
- histories = create_histories(yaml_hash: yaml_hash)
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
- annotation_parser = AnnotationParser.new(yaml_hash: yaml_hash)
138
- annotation_parser.create
140
+ annotation_parser = AnnotationParser.new(yaml_hash: yaml_hash)
141
+ annotation_parser.create
139
142
 
140
- add_annotations(histories: histories, annotation_parser: annotation_parser)
141
- end
143
+ add_annotations(histories: histories, annotation_parser: annotation_parser)
144
+ end
142
145
 
143
- #
144
- # 変更履歴を読み込む
145
- #
146
- # @param [Hash] yaml_hash 設定ファイルテキスト
147
- #
148
- # @return [Array<MonthHistory>] 変更履歴
149
- #
150
- def self.create_histories(yaml_hash: {})
151
- result = []
152
- yaml_hash.each do |month|
153
- next unless Operation::TypeParser.modified?(str: month['modified'])
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
- result.push(
156
- create_history(yaml_hash: month)
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
- result
160
- end
161
- private_class_method :create_histories
162
-
163
- def self.create_history(yaml_hash: {})
164
- diffs = MonthDiffsParser.create(yaml_hash: yaml_hash['diffs'])
165
-
166
- western_date = Operation::TypeParser.western_date(str: yaml_hash['western_date'])
167
- reference = Reference.new(page: yaml_hash['page'].to_i, number: yaml_hash['number'].to_i,
168
- japan_date: yaml_hash['japan_date'])
169
- MonthHistory.new(id: yaml_hash['id'],
170
- parent_id: Operation::TypeParser.text(str: yaml_hash['parent_id']),
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
- result
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
- history_annotations
204
- end
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
- def self.add_annotation(history_annotations: [], annotations: {}, id: '')
207
- annotation = annotations.fetch(id, Annotation.new)
208
- return if annotation.invalid?
205
+ history_annotations
206
+ end
209
207
 
210
- history_annotations.push(annotation)
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: @annotations, relations: @relations
243
+ hash: month, annotations: annotations, relations: relations
242
244
  )
243
245
  end
244
246
  end
245
247
 
246
- #
247
- # 月別履歴情報から注釈情報を取り出す
248
- #
249
- # @param [<Type>] hash 月別履歴情報yaml
250
- # @param [Hash<String, Annotation>] annotations 注釈
251
- # @param [Hash<String, String>] relations 関連注釈の対応関係
252
- #
253
- def self.resolve_history(hash: {}, annotations: {}, relations: {})
254
- id = hash['id']
255
- annotations[id] = Annotation.new(
256
- id: id,
257
- description: Operation::TypeParser.text(str: hash['description']),
258
- note: Operation::TypeParser.text(str: hash['note'])
259
- )
260
- relation_id = hash['relation_id']
261
-
262
- return if Operation::TypeParser.invalid?(str: relation_id)
263
-
264
- relations[id] = relation_id
265
- end
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
- @annotations.fetch(id, Annotation.new)
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
- def self.create(yaml_hash: {})
307
- Diffs.new(
308
- month: create_month(yaml_hash: yaml_hash['month']),
309
- solar_term: create_solar_term(yaml_hash: yaml_hash['solar_term']),
310
- days: Operation::TypeParser.days(str: yaml_hash['days'])
311
- )
312
- end
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
- def self.create_solar_term(yaml_hash: {})
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
- def self.create_month_number(yaml_hash: {})
351
- Number.new(
352
- src: Operation::TypeParser.month_number(str: yaml_hash['src']),
353
- dest: Operation::TypeParser.month_number(str: yaml_hash['dest'])
354
- )
355
- end
356
- private_class_method :create_month_number
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
- def self.create_month_leaped(yaml_hash: {})
359
- Leaped.new(
360
- src: Operation::TypeParser.month_leaped(str: yaml_hash['src']),
361
- dest: Operation::TypeParser.month_leaped(str: yaml_hash['dest'])
362
- )
363
- end
364
- private_class_method :create_month_leaped
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
- def self.create_month_day(yaml_hash: {})
367
- Days.new(
368
- src: yaml_hash['src'],
369
- dest: yaml_hash['dest']
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
- @days == INVALID_DAY_VALUE
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
- @source.invalid? && @destination.invalid?
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
- @index == -1
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
- @index == -1
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
- @src == -1 || @dest == -1
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
- @src - @dest
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
- !@src && !@dest
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
  #