zakuro 0.2.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -1
  3. data/VERSION +1 -0
  4. data/doc/gengou.md +22 -22
  5. data/doc/operation/csv/month.csv +468 -202
  6. data/doc/operation/operation.xlsx +0 -0
  7. data/lib/zakuro/calculation/base/gengou.rb +82 -0
  8. data/lib/zakuro/calculation/base/linear_gengou.rb +76 -0
  9. data/lib/zakuro/calculation/base/operated_year.rb +104 -0
  10. data/lib/zakuro/calculation/base/year.rb +28 -13
  11. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +29 -29
  12. data/lib/zakuro/calculation/gengou/internal/counter.rb +129 -0
  13. data/lib/zakuro/calculation/gengou/internal/reserve/interval.rb +183 -0
  14. data/lib/zakuro/calculation/gengou/internal/reserve/list.rb +382 -0
  15. data/lib/zakuro/calculation/gengou/internal/reserve.rb +42 -0
  16. data/lib/zakuro/calculation/gengou/scroll.rb +262 -0
  17. data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
  18. data/lib/zakuro/calculation/monthly/month.rb +49 -2
  19. data/lib/zakuro/calculation/monthly/operated_month.rb +49 -5
  20. data/lib/zakuro/calculation/range/full_range.rb +65 -103
  21. data/lib/zakuro/calculation/range/operated_range.rb +73 -23
  22. data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -17
  23. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +54 -0
  24. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +25 -21
  25. data/lib/zakuro/calculation/specifier/single_day.rb +13 -35
  26. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +9 -7
  27. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +19 -0
  28. data/lib/zakuro/calculation/summary/single.rb +5 -2
  29. data/lib/zakuro/calculation/version/internal/crawler.rb +51 -0
  30. data/lib/zakuro/calculation/version/internal/range.rb +39 -0
  31. data/lib/zakuro/calculation/version/version.rb +24 -0
  32. data/lib/zakuro/era/japan/calendar.rb +133 -0
  33. data/lib/zakuro/era/japan/gengou/parser.rb +95 -25
  34. data/lib/zakuro/era/japan/gengou/type.rb +148 -41
  35. data/lib/zakuro/era/japan/gengou/validator.rb +157 -52
  36. data/lib/zakuro/era/japan/gengou/yaml/set-001-until-south.yaml +1870 -0
  37. data/lib/zakuro/era/japan/gengou/yaml/set-002-from-north.yaml +810 -0
  38. data/lib/zakuro/era/japan/gengou/yaml/set-003-modern.yaml +50 -0
  39. data/lib/zakuro/era/japan/gengou.rb +5 -5
  40. data/lib/zakuro/era/japan/version.rb +151 -0
  41. data/lib/zakuro/era/{western.rb → western/calendar.rb} +0 -0
  42. data/lib/zakuro/merchant.rb +12 -3
  43. data/lib/zakuro/operation/month/parser.rb +1 -1
  44. data/lib/zakuro/operation/month/type.rb +59 -1
  45. data/lib/zakuro/operation/month/validator.rb +1 -1
  46. data/lib/zakuro/operation/yaml/month.yaml +8512 -0
  47. data/lib/zakuro/output/response.rb +5 -5
  48. data/lib/zakuro/tools/typeconv.rb +38 -0
  49. data/lib/zakuro/tools/typeof.rb +4 -1
  50. data/lib/zakuro/version/context.rb +25 -4
  51. data/lib/zakuro/version/daien/const/number.rb +55 -0
  52. data/lib/zakuro/version/daien/const/remainder.rb +53 -0
  53. data/lib/zakuro/version/daien/cycle/remainder.rb +85 -0
  54. data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
  55. data/lib/zakuro/version/daien/daien.rb +11 -0
  56. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
  57. data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
  58. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
  59. data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
  60. data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
  61. data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
  62. data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
  63. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
  64. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
  65. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
  66. data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
  67. data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
  68. data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
  69. data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
  70. data/lib/zakuro/version/genka/const/number.rb +43 -0
  71. data/lib/zakuro/version/genka/const/remainder.rb +33 -0
  72. data/lib/zakuro/version/genka/cycle/remainder.rb +92 -0
  73. data/lib/zakuro/version/genka/cycle/solar_term.rb +34 -0
  74. data/lib/zakuro/version/genka/genka.rb +1 -9
  75. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +95 -0
  76. data/lib/zakuro/version/genka/range/annual_range.rb +77 -0
  77. data/lib/zakuro/version/genka/stella/origin/first_term.rb +55 -0
  78. data/lib/zakuro/version/genka/stella/origin/january.rb +49 -0
  79. data/lib/zakuro/version/genka/stella/solar/average.rb +41 -0
  80. data/lib/zakuro/version/gihou/const/remainder.rb +0 -2
  81. data/lib/zakuro/version/gihou/cycle/remainder.rb +27 -6
  82. data/lib/zakuro/version/gihou/gihou.rb +1 -30
  83. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +1 -1
  84. data/lib/zakuro/version/gihou/stella/lunar/location.rb +2 -8
  85. data/lib/zakuro/version/gihou/stella/lunar/value.rb +3 -2
  86. data/lib/zakuro/version/gihou/stella/solar/average.rb +3 -3
  87. data/lib/zakuro/version/gregorio/gregorio.rb +1 -9
  88. data/lib/zakuro/version/houryaku/houryaku.rb +1 -9
  89. data/lib/zakuro/version/joukyou/joukyou.rb +1 -9
  90. data/lib/zakuro/version/kansei/kansei.rb +1 -9
  91. data/lib/zakuro/version/senmyou/const/remainder.rb +0 -2
  92. data/lib/zakuro/version/senmyou/cycle/remainder.rb +27 -6
  93. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +1 -1
  94. data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
  95. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +2 -8
  96. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +3 -2
  97. data/lib/zakuro/version/senmyou/stella/solar/average.rb +3 -3
  98. data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
  99. data/lib/zakuro/version/version_class_resolver.rb +8 -0
  100. data/zakuro.gemspec +1 -3
  101. metadata +50 -14
  102. data/lib/zakuro/calculation/base/multi_gengou.rb +0 -101
  103. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +0 -218
  104. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
  105. data/lib/zakuro/era/japan/reki.rb +0 -91
  106. data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +0 -1121
  107. data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +0 -485
  108. data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +0 -28
  109. data/lib/zakuro/version/abstract_version.rb +0 -29
  110. data/lib/zakuro/version/taien/taien.rb +0 -19
  111. data/lib/zakuro/version.rb +0 -7
  112. data/lib/zakuro/version_factory.rb +0 -59
Binary file
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../era/western/calendar'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ # :nodoc:
8
+ module Calculation
9
+ # :nodoc:
10
+ module Base
11
+ #
12
+ # Gengou 元号
13
+ #
14
+ class Gengou
15
+ # @return [Western::Calendar] 開始日
16
+ attr_reader :start_date
17
+ # @return [Western::Calendar] 終了日
18
+ attr_reader :end_date
19
+ # @return [Array<LinearGengou>] 1行目元号
20
+ attr_reader :first_line
21
+ # @return [Array<LinearGengou>] 2行目元号
22
+ attr_reader :second_line
23
+
24
+ #
25
+ # 初期化
26
+ #
27
+ # @param [Western::Calendar] start_date 開始日
28
+ # @param [Western::Calendar] end_date 終了日
29
+ # @param [Array<LinearGengou>] first_line 1行目元号
30
+ # @param [Array<LinearGengou>] second_line 2行目元号
31
+ #
32
+ def initialize(start_date: Western::Calendar.new, end_date: Western::Calendar.new,
33
+ first_line: [], second_line: [])
34
+ @start_date = start_date
35
+ @end_date = end_date
36
+ @first_line = first_line
37
+ @second_line = second_line
38
+ end
39
+
40
+ #
41
+ # 1行目元号を取得する
42
+ #
43
+ # @param [Western::Calendar] date 西暦日
44
+ #
45
+ # @return [LinearGengou] 1行目元号
46
+ #
47
+ def match_first_line(date: Western::Calendar)
48
+ @first_line.each do |line|
49
+ return line.clone if line.include?(date: date)
50
+ end
51
+
52
+ LinearGengou.new
53
+ end
54
+
55
+ #
56
+ # 2行目元号を取得する
57
+ #
58
+ # @param [Western::Calendar] date 西暦日
59
+ #
60
+ # @return [LinearGengou] 2行目元号
61
+ #
62
+ def match_second_line(date: Western::Calendar)
63
+ @second_line.each do |line|
64
+ return line.clone if line.include?(date: date)
65
+ end
66
+
67
+ LinearGengou.new
68
+ end
69
+
70
+ #
71
+ # 不正か
72
+ #
73
+ # @return [True] 不正
74
+ # @return [False] 不正なし
75
+ #
76
+ def invalid?
77
+ @first_line.size.zero? && @second_line.size.zero?
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../era/western/calendar'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ # :nodoc:
8
+ module Calculation
9
+ # :nodoc:
10
+ module Base
11
+ #
12
+ # LinearGengou 直列元号
13
+ #
14
+ class LinearGengou
15
+ INVALID_YEAR = -1
16
+
17
+ # @return [Western::Calendar] 開始日
18
+ attr_reader :start_date
19
+ # @return [Western::Calendar] 終了日
20
+ attr_reader :end_date
21
+ # @return [String] 元号名
22
+ attr_reader :name
23
+ # @return [Integer] 年
24
+ attr_reader :year
25
+
26
+ #
27
+ # 初期化
28
+ #
29
+ # @param [Western::Calendar] start_date 開始日
30
+ # @param [Western::Calendar] end_date 終了日
31
+ # @param [String] name 元号名
32
+ # @param [Integer] 元号年
33
+ #
34
+ def initialize(start_date: Western::Calendar.new, end_date: Western::Calendar.new,
35
+ name: '', year: INVALID_YEAR)
36
+ @start_date = start_date
37
+ @end_date = end_date
38
+ @name = name
39
+ @year = year
40
+ end
41
+
42
+ #
43
+ # 不正か
44
+ #
45
+ # @return [True] 不正
46
+ # @return [False] 不正なし
47
+ #
48
+ def invalid?
49
+ @name == '' || @year == INVALID_YEAR
50
+ end
51
+
52
+ #
53
+ # 範囲内か
54
+ #
55
+ # @param [Western::Calendar] date 西暦日
56
+ #
57
+ # @return [True] 範囲内
58
+ # @return [False] 範囲外
59
+ #
60
+ def include?(date: Western::Calendar.new)
61
+ return false if invalid?
62
+
63
+ return false if @start_date.invalid?
64
+
65
+ return false if @end_date.invalid?
66
+
67
+ return false if date < @start_date
68
+
69
+ return false if date > @end_date
70
+
71
+ true
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './year'
4
+
5
+ require_relative '../../version/context'
6
+
7
+ # :nodoc:
8
+ module Zakuro
9
+ # :nodoc:
10
+ module Calculation
11
+ # :nodoc:
12
+ module Base
13
+ #
14
+ # OperatedYear 年(運用)
15
+ #
16
+ class OperatedYear < Year
17
+ #
18
+ # 初期化
19
+ #
20
+ # @param [Context] context 暦コンテキスト
21
+ # @param [Array<OperatedMonth>] months 年内の全ての月
22
+ # @param [Integer] total_days 年の日数
23
+ #
24
+ def initialize(context: Context.new, months: [], total_days: 0)
25
+ super(context: context, months: months, total_days: total_days)
26
+ end
27
+
28
+ #
29
+ # 引数を月の先頭に加える
30
+ #
31
+ # @param [Array<OperatedMonth>] first_months 先頭の月
32
+ #
33
+ def unshift_months(first_months)
34
+ # 逆順で加える
35
+ first_months.reverse_each do |month|
36
+ month.moved
37
+ months.unshift(month)
38
+ end
39
+ end
40
+
41
+ #
42
+ # 引数を月の最後に加える
43
+ #
44
+ # @param [Array<OperatedMonth>] last_months 最後の月
45
+ #
46
+ def push_months(last_months)
47
+ last_months.each do |month|
48
+ month.moved
49
+ months.push(month)
50
+ end
51
+ end
52
+
53
+ #
54
+ # 昨年に属する月を取り出す
55
+ #
56
+ # @return [Array<OperatedMonth>] 昨年に属する月
57
+ #
58
+ def shift_last_year_months
59
+ result, @months = OperatedYear.devide_with(method: :last_year?, arr: months)
60
+
61
+ result
62
+ end
63
+
64
+ #
65
+ # 来年に属する月を取り出す
66
+ #
67
+ # @return [Array<OperatedMonth>] 来年に属する月
68
+ #
69
+ def pop_next_year_months
70
+ result, @months = OperatedYear.devide_with(method: :next_year?, arr: months)
71
+
72
+ result
73
+ end
74
+
75
+ # :reek:TooManyStatements { max_statements: 8 }
76
+
77
+ #
78
+ # メソッドで配列を分離する
79
+ #
80
+ # @param [Symbol] method 条件メソッド
81
+ # @param [Array<Object>] arr 配列
82
+ #
83
+ # @return [Array<Object>] 一致配列
84
+ # @return [Array<Object>] 不一致配列
85
+ #
86
+ def self.devide_with(method:, arr: [])
87
+ match = []
88
+ unmatch = []
89
+
90
+ arr.each do |item|
91
+ if !item.moved? && item.send(method)
92
+ match.push(item)
93
+ next
94
+ end
95
+
96
+ unmatch.push(item)
97
+ end
98
+
99
+ [match, unmatch]
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
@@ -2,6 +2,10 @@
2
2
 
3
3
  require_relative '../cycle/zodiac'
4
4
 
5
+ require_relative '../../era/western/calendar'
6
+
7
+ require_relative '../../version/context'
8
+
5
9
  # :nodoc:
6
10
  module Zakuro
7
11
  # :nodoc:
@@ -12,25 +16,23 @@ module Zakuro
12
16
  # Year 年
13
17
  #
14
18
  class Year
15
- # @return [Gengou] 元号
16
- attr_reader :multi_gengou
19
+ # @return [Context] 暦コンテキスト
20
+ attr_reader :context
17
21
  # @return [Array<Month>] 年内の全ての月
18
22
  attr_reader :months
19
23
  # @return [Integer] 年の日数
20
24
  attr_reader :total_days
21
- # @return [Western::Calendar] 元旦
22
- attr_reader :new_year_date
23
25
 
24
26
  #
25
27
  # 初期化
26
28
  #
27
- # @param [Gengou] multi_gengou 元号
29
+ # @param [Context] context 暦コンテキスト
30
+ # @param [Array<Month>] months 年内の全ての月
31
+ # @param [Integer] total_days 年の日数
28
32
  #
29
- def initialize(multi_gengou: MultiGengou.new, new_year_date: Western::Calendar.new,
30
- months: [], total_days: 0)
31
- @multi_gengou = multi_gengou
33
+ def initialize(context: Context.new, months: [], total_days: 0)
34
+ @context = context
32
35
  @months = months
33
- @new_year_date = new_year_date
34
36
  @total_days = total_days
35
37
  end
36
38
 
@@ -55,21 +57,34 @@ module Zakuro
55
57
  # @return [MultiGengou] 自身
56
58
  #
57
59
  def next_year
58
- @multi_gengou.next_year
59
-
60
- @new_year_date += @total_days
61
60
  @total_days = 0
62
61
 
63
62
  self
64
63
  end
65
64
 
65
+ #
66
+ # 年初を取得する
67
+ #
68
+ # @return [Western::Calendar] 年初
69
+ #
70
+ def new_year_date
71
+ return Western::Calendar.new unless months
72
+
73
+ return Western::Calendar.new if months.size.zero?
74
+
75
+ @months[0].western_date
76
+ end
77
+
66
78
  #
67
79
  # 十干十二支を取得する
68
80
  #
69
81
  # @return [String] 十干十二支
70
82
  #
71
83
  def zodiac_name
72
- Cycle::Zodiac.year_name(western_year: @new_year_date.year)
84
+ date = new_year_date
85
+ return '' if date.invalid?
86
+
87
+ Cycle::Zodiac.year_name(western_year: date.year)
73
88
  end
74
89
 
75
90
  #
@@ -10,6 +10,11 @@ module Zakuro
10
10
  # 大余小余(時刻情報)
11
11
  # @abstract 大余小余計算に必要な処理を行う、暦に依存しない汎用的なクラス
12
12
  #
13
+ # * 十干十二支(60日)を上限とした「日時分秒」の情報で、日付(date)/時刻(time)と部分的に重なる概念
14
+ # * 「15日1012分5秒」のような形式で表される
15
+ # * 分の上限で大余に繰り上げる
16
+ # * 秒の上限で1分に繰り上げる
17
+ #
13
18
  class AbstractRemainder # rubocop:disable Metrics/ClassLength
14
19
  # @return [Integer] 大余上限
15
20
  LIMIT = 60
@@ -224,8 +229,7 @@ module Zakuro
224
229
  # @return [False] より小さい
225
230
  #
226
231
  def >=(other)
227
- up?(other) || \
228
- (@day == other.day && @minute == other.minute && @second == other.second)
232
+ up?(other) || eql?(other)
229
233
  end
230
234
 
231
235
  #
@@ -249,8 +253,7 @@ module Zakuro
249
253
  # @return [False] より大きい
250
254
  #
251
255
  def <=(other)
252
- down?(other) || \
253
- (@day == other.day && @minute == other.minute && @second == other.second)
256
+ down?(other) || eql?(other)
254
257
  end
255
258
 
256
259
  #
@@ -339,10 +342,19 @@ module Zakuro
339
342
  # @return [Integer] 小余(秒切り捨て)
340
343
  #
341
344
  def floor_minute
342
- result = @minute + @second / @base_minute
345
+ result = float_minute
343
346
  result.floor
344
347
  end
345
348
 
349
+ #
350
+ # 秒を含めた小余を返す
351
+ #
352
+ # @return [Float] 小余
353
+ #
354
+ def float_minute
355
+ @minute + @second.to_f / @base_minute
356
+ end
357
+
346
358
  #
347
359
  # 大余に四捨五入した結果を返す(秒は除外する)
348
360
  #
@@ -365,26 +377,18 @@ module Zakuro
365
377
  end
366
378
 
367
379
  #
368
- # 特定の文字フォーマットにして出力する
380
+ # 繰り上げる
369
381
  #
370
- # @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
382
+ # @return [AbstractRemainder] 繰り上げ結果
371
383
  #
372
- # @return [String] フォーマットした結果
373
- #
374
- def format(form: '%d-%d')
375
- return '' if invalid?
384
+ def carry!
385
+ @day, @minute, @second = carry(@day, @minute, @second)
376
386
 
377
- super(form, @day, @minute, @second)
387
+ self
378
388
  end
379
389
 
380
390
  private
381
391
 
382
- def carry!(day, minute, second)
383
- @day, @minute, @second = carry(day, minute, second)
384
-
385
- self
386
- end
387
-
388
392
  # 繰り上げ、繰り下げ
389
393
  def carry(param_day, param_minute, param_second)
390
394
  # NOTE: 計算方法としてマイナスでも徐算・剰余算の結果をプラス同様に扱う
@@ -437,33 +441,29 @@ module Zakuro
437
441
  def up?(other)
438
442
  invalid?(param: other)
439
443
  day = other.day
440
- minute = other.minute
444
+ minute = other.float_minute
445
+
441
446
  return true if @day > day
442
447
  return false if @day < day
443
448
 
444
- return true if @minute > minute
445
- return false if @minute < minute
446
-
447
- @second > other.second
449
+ float_minute > minute
448
450
  end
449
451
 
450
452
  def eql?(other)
451
453
  invalid?(param: other)
452
454
 
453
- (@day == other.day && @minute == other.minute && @second == other.second)
455
+ (@day == other.day && float_minute == other.float_minute)
454
456
  end
455
457
 
456
458
  def down?(other)
457
459
  invalid?(param: other)
458
460
  day = other.day
459
- minute = other.minute
461
+ minute = other.float_minute
462
+
460
463
  return true if @day < day
461
464
  return false if @day > day
462
465
 
463
- return true if @minute < minute
464
- return false if @minute > minute
465
-
466
- @second < other.second
466
+ float_minute < minute
467
467
  end
468
468
  end
469
469
  end
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../era/japan/gengou'
4
+ require_relative '../../../era/japan/calendar'
5
+ require_relative '../../../era/western/calendar'
6
+
7
+ # :nodoc:
8
+ module Zakuro
9
+ # :nodoc:
10
+ module Calculation
11
+ # :nodoc:
12
+ module Gengou
13
+ #
14
+ # Counter 加算元号
15
+ #
16
+ class Counter
17
+ # @return [Integer] 不正値
18
+ INVALID_YEAR = -1
19
+
20
+ # @return [Japan::Gengou] 元号
21
+ attr_reader :gengou
22
+ # @return [Integer] 元号年
23
+ attr_reader :japan_year
24
+ # @return [Integer] 西暦年
25
+ attr_reader :western_year
26
+
27
+ #
28
+ # 初期化
29
+ #
30
+ # @param [Japan::Gengou] gengou 元号
31
+ #
32
+ def initialize(gengou: Japan::Gengou.new)
33
+ @gengou = gengou
34
+ @japan_year = gengou.both_start_year.japan
35
+ @western_year = gengou.both_start_year.western
36
+ end
37
+
38
+ #
39
+ # 和暦開始日を取得する
40
+ #
41
+ # @return [Japan::Calendar] 和暦開始日
42
+ #
43
+ def japan_start_date
44
+ return Japan::Calendar.new if @gengou.invalid?
45
+
46
+ @gengou.both_start_date.japan
47
+ end
48
+
49
+ #
50
+ # 西暦開始日を取得する
51
+ #
52
+ # @return [Western::Calendar] 西暦開始日
53
+ #
54
+ def western_start_date
55
+ return Western::Calendar.new if @gengou.invalid?
56
+
57
+ @gengou.both_start_date.western
58
+ end
59
+
60
+ #
61
+ # 西暦終了日を取得する
62
+ #
63
+ # @return [Western::Calendar] 西暦終了日
64
+ #
65
+ def western_end_date
66
+ return Western::Calendar.new if @gengou.invalid?
67
+
68
+ @gengou.end_date
69
+ end
70
+
71
+ #
72
+ # 次年にする
73
+ #
74
+ # @return [MultiGengou] 自身
75
+ #
76
+ def next_year
77
+ @japan_year += 1
78
+ @western_year += 1
79
+
80
+ self
81
+ end
82
+
83
+ #
84
+ # 元号名を取得する
85
+ #
86
+ # @return [String] 元号名
87
+ #
88
+ def name
89
+ return '' unless @gengou
90
+
91
+ @gengou.name
92
+ end
93
+
94
+ #
95
+ # 不正か
96
+ #
97
+ # @return [True] 不正
98
+ # @return [False] 不正なし
99
+ #
100
+ def invalid?
101
+ @gengou.invalid? || @japan_year == INVALID_YEAR || @western_year == INVALID_YEAR
102
+ end
103
+
104
+ #
105
+ # 指定した日が元号に含まれるか
106
+ #
107
+ # @param [Western::Calendar] date 日
108
+ #
109
+ # @return [True] 含まれる
110
+ # @return [False] 含まれない
111
+ #
112
+ def include?
113
+ @gengou.include?
114
+ end
115
+
116
+ #
117
+ # ディープコピー
118
+ #
119
+ # @param [MultiGengou] obj 自身
120
+ #
121
+ def initialize_copy(obj)
122
+ @gengou = obj.gengou.clone
123
+ @japan_year = obj.japan_year
124
+ @western_year = obj.western_year
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end