zakuro 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -13
  3. data/VERSION +1 -1
  4. data/doc/dropped_date.md +93 -0
  5. data/doc/error.md +45 -0
  6. data/doc/operation/csv/month.csv +100 -79
  7. data/doc/operation/operation.xlsx +0 -0
  8. data/lib/zakuro/calculation/base/day.rb +52 -0
  9. data/lib/zakuro/calculation/base/gengou.rb +5 -5
  10. data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
  11. data/lib/zakuro/calculation/base/operated_year.rb +26 -24
  12. data/lib/zakuro/calculation/base/year.rb +7 -7
  13. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
  14. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
  15. data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
  16. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +38 -29
  17. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
  18. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
  19. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
  22. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
  23. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
  24. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
  25. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
  26. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
  27. data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
  28. data/lib/zakuro/calculation/era/version/version.rb +12 -10
  29. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
  30. data/lib/zakuro/calculation/monthly/const.rb +18 -0
  31. data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
  32. data/lib/zakuro/calculation/monthly/month.rb +17 -17
  33. data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
  34. data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
  35. data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
  36. data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
  37. data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
  38. data/lib/zakuro/calculation/range/abstract_full_range.rb +40 -25
  39. data/lib/zakuro/calculation/range/abstract_operation_range.rb +111 -109
  40. data/lib/zakuro/calculation/range/dated_full_range.rb +1 -1
  41. data/lib/zakuro/calculation/range/dated_operation_range.rb +1 -1
  42. data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
  43. data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
  44. data/lib/zakuro/calculation/range/named_operation_range.rb +1 -1
  45. data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
  46. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
  47. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
  48. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
  49. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
  50. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
  51. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
  52. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
  53. data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
  54. data/lib/zakuro/calculation/summary/internal/month.rb +32 -11
  55. data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
  56. data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
  57. data/lib/zakuro/calculation/summary/japan/range.rb +145 -118
  58. data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
  59. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +57 -50
  60. data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
  61. data/lib/zakuro/calculation/summary/western/range.rb +95 -92
  62. data/lib/zakuro/calculation/summary/western/single.rb +78 -76
  63. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -119
  64. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +63 -56
  65. data/lib/zakuro/calculation/type/old_float.rb +2 -2
  66. data/lib/zakuro/calculation/type/optional.rb +46 -0
  67. data/lib/zakuro/condition.rb +142 -92
  68. data/lib/zakuro/context/context.rb +44 -0
  69. data/lib/zakuro/context/option.rb +119 -0
  70. data/lib/zakuro/context/version_class_resolver.rb +112 -0
  71. data/lib/zakuro/era/japan/calendar.rb +35 -33
  72. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +8 -4
  73. data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
  74. data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
  75. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
  76. data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
  77. data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -34
  78. data/lib/zakuro/era/japan/gengou/resource/type.rb +45 -37
  79. data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
  80. data/lib/zakuro/era/japan/gengou.rb +28 -26
  81. data/lib/zakuro/era/japan/version.rb +18 -16
  82. data/lib/zakuro/era/western/calendar.rb +104 -88
  83. data/lib/zakuro/exception/case/pattern.rb +39 -3
  84. data/lib/zakuro/exception/case/preset.rb +2 -2
  85. data/lib/zakuro/exception/exception.rb +17 -15
  86. data/lib/zakuro/exception/zakuro_error.rb +19 -1
  87. data/lib/zakuro/gateway/locale/date.rb +2 -2
  88. data/lib/zakuro/gateway/locale/range.rb +3 -3
  89. data/lib/zakuro/gateway/range.rb +3 -3
  90. data/lib/zakuro/gateway/single.rb +14 -3
  91. data/lib/zakuro/merchant.rb +79 -9
  92. data/lib/zakuro/operation/month/parser.rb +252 -249
  93. data/lib/zakuro/operation/month/type.rb +17 -8
  94. data/lib/zakuro/operation/month/validator.rb +148 -144
  95. data/lib/zakuro/operation/operation.rb +38 -36
  96. data/lib/zakuro/operation/yaml/month.yaml +955 -281
  97. data/lib/zakuro/output/response.rb +107 -141
  98. data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
  99. data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
  100. data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
  101. data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
  102. data/lib/zakuro/result/data/single_day.rb +9 -1
  103. data/lib/zakuro/result/operation/month/annotation.rb +2 -2
  104. data/lib/zakuro/result/operation/month/history.rb +2 -2
  105. data/lib/zakuro/result/operation/month.rb +31 -0
  106. data/lib/zakuro/result/operation.rb +39 -0
  107. data/lib/zakuro/result/result.rb +3 -3
  108. data/lib/zakuro/tools/stringifier.rb +67 -42
  109. data/lib/zakuro/tools/typeconv.rb +17 -15
  110. data/lib/zakuro/tools/typeof.rb +15 -13
  111. data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
  112. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
  113. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
  114. data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
  115. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
  116. data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
  117. data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
  118. data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
  119. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
  120. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
  121. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
  122. data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
  123. data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
  124. data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
  125. data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
  126. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
  127. data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
  128. data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
  129. data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
  130. data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
  131. data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
  132. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
  133. data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
  134. data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
  135. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
  136. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
  137. data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
  138. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
  139. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
  140. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
  141. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
  142. data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
  143. data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
  144. data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
  145. data/lib/zakuro/version/senmyou/const/remainder.rb +7 -1
  146. data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
  147. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
  148. data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
  149. data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
  150. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
  151. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
  152. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
  153. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
  154. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
  155. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
  156. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
  157. data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
  158. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
  159. data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
  160. metadata +27 -7
  161. data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
  162. data/lib/zakuro/result/operation/month/bundle.rb +0 -36
  163. data/lib/zakuro/result/operation/operation.rb +0 -44
  164. data/lib/zakuro/version/context.rb +0 -44
  165. data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -15,199 +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
- def self.run(filepath:)
116
- hash = YAML.load_file(filepath)
117
-
118
- failed = Validator.run(yaml_hash: hash)
119
-
120
- raise ArgumentError, failed.join("\n") unless failed.empty?
121
-
122
- load(yaml_hash: hash)
123
- 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
124
129
 
125
- #
126
- # 設定ファイルを読み込む
127
- #
128
- # @param [Hash] yaml_hash 設定ファイルテキスト
129
- #
130
- # @return [Array<MonthHistory>] 変更履歴
131
- #
132
- def self.load(yaml_hash: {})
133
- 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)
134
139
 
135
- annotation_parser = AnnotationParser.new(yaml_hash: yaml_hash)
136
- annotation_parser.create
140
+ annotation_parser = AnnotationParser.new(yaml_hash: yaml_hash)
141
+ annotation_parser.create
137
142
 
138
- add_annotations(histories: histories, annotation_parser: annotation_parser)
139
- end
143
+ add_annotations(histories: histories, annotation_parser: annotation_parser)
144
+ end
140
145
 
141
- #
142
- # 変更履歴を読み込む
143
- #
144
- # @param [Hash] yaml_hash 設定ファイルテキスト
145
- #
146
- # @return [Array<MonthHistory>] 変更履歴
147
- #
148
- def self.create_histories(yaml_hash: {})
149
- result = []
150
- yaml_hash.each do |month|
151
- 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
152
166
 
153
- result.push(
154
- create_history(yaml_hash: month)
155
- )
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)
156
178
  end
157
- result
158
- end
159
- private_class_method :create_histories
160
-
161
- def self.create_history(yaml_hash: {})
162
- diffs = MonthDiffsParser.create(yaml_hash: yaml_hash['diffs'])
163
-
164
- western_date = Operation::TypeParser.western_date(str: yaml_hash['western_date'])
165
- reference = Reference.new(page: yaml_hash['page'].to_i, number: yaml_hash['number'].to_i,
166
- japan_date: yaml_hash['japan_date'])
167
- MonthHistory.new(id: yaml_hash['id'],
168
- parent_id: Operation::TypeParser.text(str: yaml_hash['parent_id']),
169
- reference: reference,
170
- western_date: western_date,
171
- diffs: diffs)
172
- end
173
- private_class_method :create_history
174
-
175
- def self.add_annotations(annotation_parser:, histories: [])
176
- result = []
177
- histories.each do |history|
178
- id = history.id
179
- result.push(
180
- MonthHistory.new(
181
- id: id, parent_id: history.parent_id, reference: history.reference,
182
- western_date: history.western_date,
183
- annotations: annotation_parser.specify(id: id),
184
- 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
+ )
185
191
  )
186
- )
187
- end
192
+ end
188
193
 
189
- result
190
- end
191
- private_class_method :add_annotations
192
-
193
- def self.create_history_annnotations(history:, annotations: {}, relations: {})
194
- history_id = history.id
195
- history_annotations = []
196
- [history_id, relations.fetch(history_id, '')].each do |id|
197
- add_annotation(history_annotations: history_annotations,
198
- annotations: annotations, id: id)
194
+ result
199
195
  end
200
196
 
201
- history_annotations
202
- 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
203
204
 
204
- def self.add_annotation(history_annotations: [], annotations: {}, id: '')
205
- annotation = annotations.fetch(id, Annotation.new)
206
- return if annotation.invalid?
205
+ history_annotations
206
+ end
207
207
 
208
- 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
209
214
  end
210
- private_class_method :add_annotation
211
215
  end
212
216
 
213
217
  #
@@ -236,31 +240,33 @@ module Zakuro
236
240
  def create
237
241
  @yaml_hash.each do |month|
238
242
  AnnotationParser.resolve_history(
239
- hash: month, annotations: @annotations, relations: @relations
243
+ hash: month, annotations: annotations, relations: relations
240
244
  )
241
245
  end
242
246
  end
243
247
 
244
- #
245
- # 月別履歴情報から注釈情報を取り出す
246
- #
247
- # @param [<Type>] hash 月別履歴情報yaml
248
- # @param [Hash<String, Annotation>] annotations 注釈
249
- # @param [Hash<String, String>] relations 関連注釈の対応関係
250
- #
251
- def self.resolve_history(hash: {}, annotations: {}, relations: {})
252
- id = hash['id']
253
- annotations[id] = Annotation.new(
254
- id: id,
255
- description: Operation::TypeParser.text(str: hash['description']),
256
- note: Operation::TypeParser.text(str: hash['note'])
257
- )
258
- relation_id = hash['relation_id']
259
-
260
- return if Operation::TypeParser.invalid?(str: relation_id)
261
-
262
- relations[id] = relation_id
263
- 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
264
270
 
265
271
  #
266
272
  # 注釈を特定する
@@ -293,7 +299,7 @@ module Zakuro
293
299
  end
294
300
 
295
301
  def annotation(id: '')
296
- @annotations.fetch(id, Annotation.new)
302
+ annotations.fetch(id, Annotation.new)
297
303
  end
298
304
  end
299
305
 
@@ -301,73 +307,70 @@ module Zakuro
301
307
  # MonthDiffsParser 月情報(差分)解析
302
308
  #
303
309
  module MonthDiffsParser
304
- def self.create(yaml_hash: {})
305
- Diffs.new(
306
- month: create_month(yaml_hash: yaml_hash['month']),
307
- solar_term: create_solar_term(yaml_hash: yaml_hash['solar_term']),
308
- days: Operation::TypeParser.days(str: yaml_hash['days'])
309
- )
310
- 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
311
318
 
312
- def self.create_solar_term(yaml_hash: {})
313
- SolarTerm::Direction.new(
314
- source: create_source_solar_term(yaml_hash: yaml_hash['src']),
315
- destination: create_destination_solar_term(yaml_hash: yaml_hash['dest']),
316
- days: Operation::TypeParser.days(str: yaml_hash['days'])
317
- )
318
- end
319
- private_class_method :create_solar_term
320
-
321
- def self.create_source_solar_term(yaml_hash: {})
322
- SolarTerm::Source.new(
323
- index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
324
- to: Operation::TypeParser.western_date(str: yaml_hash['to']),
325
- zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
326
- )
327
- end
328
- private_class_method :create_source_solar_term
329
-
330
- def self.create_destination_solar_term(yaml_hash: {})
331
- SolarTerm::Destination.new(
332
- index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
333
- from: Operation::TypeParser.western_date(str: yaml_hash['from']),
334
- zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
335
- )
336
- end
337
- private_class_method :create_destination_solar_term
338
-
339
- def self.create_month(yaml_hash: {})
340
- Month.new(
341
- number: create_month_number(yaml_hash: yaml_hash['number']),
342
- leaped: create_month_leaped(yaml_hash: yaml_hash['leaped']),
343
- is_many_days: create_month_day(yaml_hash: yaml_hash['days'])
344
- )
345
- end
346
- private_class_method :create_month
319
+ private
347
320
 
348
- def self.create_month_number(yaml_hash: {})
349
- Number.new(
350
- src: Operation::TypeParser.month_number(str: yaml_hash['src']),
351
- dest: Operation::TypeParser.month_number(str: yaml_hash['dest'])
352
- )
353
- end
354
- 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
355
328
 
356
- def self.create_month_leaped(yaml_hash: {})
357
- Leaped.new(
358
- src: Operation::TypeParser.month_leaped(str: yaml_hash['src']),
359
- dest: Operation::TypeParser.month_leaped(str: yaml_hash['dest'])
360
- )
361
- end
362
- 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
363
336
 
364
- def self.create_month_day(yaml_hash: {})
365
- Days.new(
366
- src: yaml_hash['src'],
367
- dest: yaml_hash['dest']
368
- )
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
369
373
  end
370
- private_class_method :create_month_day
371
374
  end
372
375
  end
373
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
  #