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
@@ -58,26 +58,28 @@ module Zakuro
58
58
  Type::DEFAULT => Date::ITALY
59
59
  }.freeze
60
60
 
61
- #
62
- # 日付種別からRuby標準のグレゴリオ暦開始日を引き当てる
63
- #
64
- # @param [Symbol] type 日付種別
65
- #
66
- # @return [Integer] Ruby標準のグレゴリオ暦開始日
67
- #
68
- def self.to_native_start(type:)
69
- DATE_START.fetch(type, DATE_START[Type::DEFAULT])
70
- end
61
+ class << self
62
+ #
63
+ # 日付種別からRuby標準のグレゴリオ暦開始日を引き当てる
64
+ #
65
+ # @param [Symbol] type 日付種別
66
+ #
67
+ # @return [Integer] Ruby標準のグレゴリオ暦開始日
68
+ #
69
+ def to_native_start(type:)
70
+ DATE_START.fetch(type, DATE_START[Type::DEFAULT])
71
+ end
71
72
 
72
- #
73
- # Ruby標準のグレゴリオ暦開始日から日付種別を引き当てる
74
- #
75
- # @param [Integer] start Ruby標準のグレゴリオ暦開始日
76
- #
77
- # @return [Symbol] 日付種別
78
- #
79
- def self.to_type(start:)
80
- DATE_START.invert.fetch(start, Type::DEFAULT)
73
+ #
74
+ # Ruby標準のグレゴリオ暦開始日から日付種別を引き当てる
75
+ #
76
+ # @param [Integer] start Ruby標準のグレゴリオ暦開始日
77
+ #
78
+ # @return [Symbol] 日付種別
79
+ #
80
+ def to_type(start:)
81
+ DATE_START.invert.fetch(start, Type::DEFAULT)
82
+ end
81
83
  end
82
84
 
83
85
  #
@@ -131,8 +133,16 @@ module Zakuro
131
133
  # 定数 DATE_START のバリエーションで日付オブジェクトを初期化するだけで良い
132
134
  #
133
135
  class Calendar # rubocop:disable Metrics/ClassLength
134
- attr_reader :param, :date
136
+ # @return [Parameter] 初期化引数
137
+ attr_reader :param
138
+ # @return [Date] 日付(Ruby日付型)
139
+ attr_reader :date
135
140
 
141
+ #
142
+ # 検証する
143
+ #
144
+ # @return [Array<String>] エラー文字列
145
+ #
136
146
  def validate
137
147
  failed = valid_type
138
148
 
@@ -150,9 +160,9 @@ module Zakuro
150
160
  #
151
161
  def valid_type
152
162
  failed = []
153
- year = @param.year
154
- month = @param.month
155
- day = @param.day
163
+ year = param.year
164
+ month = param.month
165
+ day = param.day
156
166
  failed.push("wrong type. year: #{year}") unless year.is_a?(Integer)
157
167
  failed.push("wrong type. month: #{month}") unless month.is_a?(Integer)
158
168
  failed.push("wrong type. day: #{day}") unless day.is_a?(Integer)
@@ -169,10 +179,10 @@ module Zakuro
169
179
  def valid_date
170
180
  failed = []
171
181
 
172
- year = @param.year
173
- month = @param.month
174
- day = @param.day
175
- start = @param.start
182
+ year = param.year
183
+ month = param.month
184
+ day = param.day
185
+ start = param.start
176
186
  unless Date.valid_date?(year, month, day, start)
177
187
  failed.push("year: #{year}, month: #{month}, " \
178
188
  "day: #{day}, start: #{start}")
@@ -215,7 +225,7 @@ module Zakuro
215
225
  #
216
226
  def redate(type: Type::DEFAULT)
217
227
  start = DATE_START.fetch(type, DATE_START[Type::DEFAULT])
218
- @date = @date.new_start(start)
228
+ @date = date.new_start(start)
219
229
  self
220
230
  end
221
231
 
@@ -227,7 +237,7 @@ module Zakuro
227
237
  # @return [Calendar] 年月日情報(西暦)
228
238
  #
229
239
  def +(other)
230
- return @date.jd + other.date.jd if other.is_a?(Western::Calendar)
240
+ return date.jd + other.date.jd if other.is_a?(Western::Calendar)
231
241
 
232
242
  @date += other
233
243
  self
@@ -241,7 +251,7 @@ module Zakuro
241
251
  # @return [Calendar] 年月日情報(西暦)
242
252
  #
243
253
  def -(other)
244
- return @date.jd - other.date.jd if other.is_a?(Western::Calendar)
254
+ return date.jd - other.date.jd if other.is_a?(Western::Calendar)
245
255
 
246
256
  @date -= other
247
257
  self
@@ -256,7 +266,7 @@ module Zakuro
256
266
  # @return [False] 以下(現在日/過去日である)
257
267
  #
258
268
  def >(other)
259
- @date > other.date
269
+ date > other.date
260
270
  end
261
271
 
262
272
  #
@@ -268,7 +278,7 @@ module Zakuro
268
278
  # @return [False] より小さい(過去日である)
269
279
  #
270
280
  def >=(other)
271
- @date >= other.date
281
+ date >= other.date
272
282
  end
273
283
 
274
284
  #
@@ -280,7 +290,7 @@ module Zakuro
280
290
  # @return [False] 以上(現在日/未来日である)
281
291
  #
282
292
  def <(other)
283
- @date < other.date
293
+ date < other.date
284
294
  end
285
295
 
286
296
  #
@@ -292,7 +302,7 @@ module Zakuro
292
302
  # @return [False] より大きい(未来日である)
293
303
  #
294
304
  def <=(other)
295
- @date <= other.date
305
+ date <= other.date
296
306
  end
297
307
 
298
308
  #
@@ -304,7 +314,7 @@ module Zakuro
304
314
  # @return [False] 等しくない(過去日/未来日である)
305
315
  #
306
316
  def ==(other)
307
- @date == other.date
317
+ date == other.date
308
318
  end
309
319
 
310
320
  #
@@ -313,7 +323,7 @@ module Zakuro
313
323
  # @return [Integer] 年
314
324
  #
315
325
  def year
316
- @date.year
326
+ date.year
317
327
  end
318
328
 
319
329
  #
@@ -322,7 +332,7 @@ module Zakuro
322
332
  # @return [Integer] 月
323
333
  #
324
334
  def month
325
- @date.month
335
+ date.month
326
336
  end
327
337
 
328
338
  #
@@ -331,7 +341,7 @@ module Zakuro
331
341
  # @return [Integer] 日
332
342
  #
333
343
  def day
334
- @date.day
344
+ date.day
335
345
  end
336
346
 
337
347
  #
@@ -342,7 +352,7 @@ module Zakuro
342
352
  # @return [Calendar] 年月日情報(西暦)
343
353
  #
344
354
  def next_year(num: 1)
345
- @date = @date.next_year(num)
355
+ @date = date.next_year(num)
346
356
  self
347
357
  end
348
358
 
@@ -353,7 +363,7 @@ module Zakuro
353
363
  # @return [False] 無効値以外
354
364
  #
355
365
  def invalid?
356
- (@date == Date.new)
366
+ (date == Date.new)
357
367
  end
358
368
 
359
369
  #
@@ -364,62 +374,64 @@ module Zakuro
364
374
  # @return [String] 年月日情報
365
375
  #
366
376
  def format(form: '%Y-%m-%d')
367
- @date.strftime(form)
377
+ date.strftime(form)
368
378
  end
369
379
 
370
- #
371
- # 年月日情報(西暦)を生成する
372
- #
373
- # @param [Date] date Ruby標準日付
374
- #
375
- # @return [Calendar] 年月日情報(西暦)
376
- #
377
- def self.create(date: Date.new)
378
- type = Western.to_type(start: date.start)
379
- Calendar.new(year: date.year, month: date.month,
380
- day: date.day, type: type)
381
- end
382
-
383
- #
384
- # 年月日情報(西暦)を生成する
385
- #
386
- # @param [String] text 日付文字列
387
- # @param [Symbol] type 日付種別
388
- #
389
- # @return [Calendar] 年月日情報(西暦)
390
- #
391
- # @raise [ArgumentError] 引数エラー
392
- #
393
- def self.parse(text: '', type: Type::DEFAULT)
394
- unless Calendar.valid_date_string(text: text, type: type)
395
- raise ArgumentError, "invalid date string: #{text}"
380
+ class << self
381
+ #
382
+ # 年月日情報(西暦)を生成する
383
+ #
384
+ # @param [Date] date Ruby標準日付
385
+ #
386
+ # @return [Calendar] 年月日情報(西暦)
387
+ #
388
+ def create(date: Date.new)
389
+ type = Western.to_type(start: date.start)
390
+ Calendar.new(year: date.year, month: date.month,
391
+ day: date.day, type: type)
396
392
  end
397
393
 
398
- start = DATE_START.fetch(type, DATE_START[Type::DEFAULT])
399
- date = Date.parse(text, start)
400
-
401
- Calendar.new(
402
- year: date.year, month: date.month, day: date.day, type: type
403
- )
404
- end
394
+ #
395
+ # 年月日情報(西暦)を生成する
396
+ #
397
+ # @param [String] text 日付文字列
398
+ # @param [Symbol] type 日付種別
399
+ #
400
+ # @return [Calendar] 年月日情報(西暦)
401
+ #
402
+ # @raise [ArgumentError] 引数エラー
403
+ #
404
+ def parse(text: '', type: Type::DEFAULT)
405
+ unless valid_date_string(text: text, type: type)
406
+ raise ArgumentError, "invalid date string: #{text}"
407
+ end
408
+
409
+ start = DATE_START.fetch(type, DATE_START[Type::DEFAULT])
410
+ date = Date.parse(text, start)
411
+
412
+ Calendar.new(
413
+ year: date.year, month: date.month, day: date.day, type: type
414
+ )
415
+ end
405
416
 
406
- #
407
- # 日付文字列を検証する
408
- #
409
- # @param [String] text 日付文字列
410
- # @param [Symbol] type 日付種別
411
- #
412
- # @return [True] 正しい
413
- # @return [True] 正しくない
414
- #
415
- def self.valid_date_string(text: '', type: Type::DEFAULT)
416
- start = DATE_START.fetch(type, DATE_START[Type::DEFAULT])
417
- begin
418
- Date.parse(text, start)
419
- rescue ArgumentError => _e
420
- return false
417
+ #
418
+ # 日付文字列を検証する
419
+ #
420
+ # @param [String] text 日付文字列
421
+ # @param [Symbol] type 日付種別
422
+ #
423
+ # @return [True] 正しい
424
+ # @return [True] 正しくない
425
+ #
426
+ def valid_date_string(text: '', type: Type::DEFAULT)
427
+ start = DATE_START.fetch(type, DATE_START[Type::DEFAULT])
428
+ begin
429
+ Date.parse(text, start)
430
+ rescue ArgumentError => _e
431
+ return false
432
+ end
433
+ true
421
434
  end
422
- true
423
435
  end
424
436
  end
425
437
  end
@@ -34,7 +34,7 @@ module Zakuro
34
34
  # @return [String] エラーコード
35
35
  #
36
36
  def code
37
- @template.code
37
+ template.code
38
38
  end
39
39
 
40
40
  #
@@ -43,7 +43,7 @@ module Zakuro
43
43
  # @return [String] メッセージ
44
44
  #
45
45
  def message
46
- @template.format(*args)
46
+ template.format(*args)
47
47
  end
48
48
  end
49
49
  end
@@ -18,20 +18,22 @@ module Zakuro
18
18
  # @return [String] 共通メッセージ
19
19
  MESSAGE = 'an error has occurred'
20
20
 
21
- #
22
- # 例外を取得する
23
- #
24
- # @param [Array<Case::Preset>] presets 原因プリセット
25
- #
26
- # @return [ZakuroError] ライブラリエラー
27
- #
28
- def self.get(presets: [])
29
- causes = []
30
- presets.each do |preset|
31
- causes.push(Cause.new(code: preset.code, message: preset.message))
32
- end
21
+ class << self
22
+ #
23
+ # 例外を取得する
24
+ #
25
+ # @param [Array<Case::Preset>] presets 原因プリセット
26
+ #
27
+ # @return [ZakuroError] ライブラリエラー
28
+ #
29
+ def get(presets: [])
30
+ causes = []
31
+ presets.each do |preset|
32
+ causes.push(Cause.new(code: preset.code, message: preset.message))
33
+ end
33
34
 
34
- ZakuroError.new(msg: MESSAGE, causes: causes)
35
+ ZakuroError.new(msg: MESSAGE, causes: causes)
36
+ end
35
37
  end
36
38
  end
37
39
  end
@@ -35,7 +35,7 @@ module Zakuro
35
35
  #
36
36
  def text
37
37
  list = []
38
- @causes.each do |cause|
38
+ causes.each do |cause|
39
39
  list.push(Tools::Stringifier.to_h(obj: cause, class_prefix: 'Zakuro'))
40
40
  end
41
41
 
@@ -51,7 +51,7 @@ module Zakuro
51
51
  # @return [False] 不正なし
52
52
  #
53
53
  def invalid_japan?
54
- @japan_date.invalid?
54
+ japan_date.invalid?
55
55
  end
56
56
 
57
57
  #
@@ -71,7 +71,7 @@ module Zakuro
71
71
  # @return [False] 不正なし
72
72
  #
73
73
  def invalid_western?
74
- @western_date.invalid?
74
+ western_date.invalid?
75
75
  end
76
76
 
77
77
  #
@@ -39,7 +39,7 @@ module Zakuro
39
39
  # @return [False] 無効
40
40
  #
41
41
  def valid_western?
42
- @start_date.valid_western? && @last_date.valid_western?
42
+ start_date.valid_western? && last_date.valid_western?
43
43
  end
44
44
 
45
45
  #
@@ -49,7 +49,7 @@ module Zakuro
49
49
  # @return [False] 無効
50
50
  #
51
51
  def valid_japan?
52
- @start_date.valid_japan? && @last_date.valid_japan?
52
+ start_date.valid_japan? && last_date.valid_japan?
53
53
  end
54
54
 
55
55
  #
@@ -59,7 +59,7 @@ module Zakuro
59
59
  # @return [False] 不正なし
60
60
  #
61
61
  def invalid?
62
- @start_date.invalid? && @last_date.invalid?
62
+ start_date.invalid? && last_date.invalid?
63
63
  end
64
64
  end
65
65
  end
@@ -38,7 +38,7 @@ module Zakuro
38
38
  # @return [False] 不正なし
39
39
  #
40
40
  def invalid?
41
- @range.invalid?
41
+ range.invalid?
42
42
  end
43
43
 
44
44
  #
@@ -36,7 +36,7 @@ module Zakuro
36
36
  # @return [False] 不正なし
37
37
  #
38
38
  def invalid?
39
- @date.invalid?
39
+ date.invalid?
40
40
  end
41
41
 
42
42
  #
@@ -57,7 +57,18 @@ module Zakuro
57
57
  )
58
58
  end
59
59
 
60
- raise Exception.get(
60
+ raise invalid_date_error
61
+ end
62
+
63
+ private
64
+
65
+ #
66
+ # 日付不正エラーを取得する
67
+ #
68
+ # @return [ZakuroError] ライブラリエラー
69
+ #
70
+ def invalid_date_error
71
+ Exception.get(
61
72
  presets: [
62
73
  Exception::Case::Preset.new(
63
74
  template: Exception::Case::Pattern::INVALID_DATE
@@ -53,7 +53,7 @@ module Zakuro
53
53
  failed = Condition.validate(hash: condition)
54
54
  raise Exception.get(presets: failed) unless failed.empty?
55
55
 
56
- @condition.rewrite(hash: condition)
56
+ condition.rewrite(hash: condition)
57
57
 
58
58
  self
59
59
  rescue Exception::ZakuroError => e