zakuro 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +3 -0
  3. data/README.md +22 -7
  4. data/VERSION +1 -0
  5. data/doc/operation/transfer.rb +8 -8
  6. data/lib/zakuro/calculation/base/gengou.rb +128 -0
  7. data/lib/zakuro/calculation/base/linear_gengou.rb +76 -0
  8. data/lib/zakuro/calculation/base/operated_year.rb +5 -15
  9. data/lib/zakuro/calculation/base/year.rb +26 -14
  10. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +209 -0
  11. data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
  12. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +107 -0
  13. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +214 -0
  14. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +104 -0
  15. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +230 -0
  16. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +193 -0
  17. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
  18. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
  19. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +158 -0
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +75 -0
  22. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +41 -0
  23. data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
  24. data/lib/zakuro/calculation/era/version/internal/crawler.rb +51 -0
  25. data/lib/zakuro/calculation/era/version/internal/range.rb +39 -0
  26. data/lib/zakuro/calculation/era/version/version.rb +24 -0
  27. data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
  28. data/lib/zakuro/calculation/monthly/month.rb +88 -2
  29. data/lib/zakuro/calculation/monthly/operated_month.rb +3 -3
  30. data/lib/zakuro/calculation/range/abstract_full_range.rb +172 -0
  31. data/lib/zakuro/calculation/range/{operated_range.rb → abstract_operation_range.rb} +17 -15
  32. data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
  33. data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
  34. data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
  35. data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
  36. data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -19
  37. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +54 -0
  38. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +25 -21
  39. data/lib/zakuro/calculation/summary/internal/month.rb +84 -0
  40. data/lib/zakuro/calculation/summary/{single.rb → internal/operation.rb} +6 -37
  41. data/lib/zakuro/calculation/summary/japan/range.rb +152 -0
  42. data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
  43. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +91 -0
  44. data/lib/zakuro/calculation/summary/western/range.rb +124 -0
  45. data/lib/zakuro/calculation/summary/western/single.rb +113 -0
  46. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +169 -0
  47. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +93 -0
  48. data/lib/zakuro/condition.rb +15 -2
  49. data/lib/zakuro/era/japan/calendar.rb +133 -0
  50. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +121 -0
  51. data/lib/zakuro/era/japan/gengou/alignment/division.rb +168 -0
  52. data/lib/zakuro/era/japan/gengou/alignment/line.rb +175 -0
  53. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +187 -0
  54. data/lib/zakuro/era/japan/gengou/alignment.rb +55 -0
  55. data/lib/zakuro/era/japan/gengou/resource/parser.rb +243 -0
  56. data/lib/zakuro/era/japan/gengou/resource/type.rb +293 -0
  57. data/lib/zakuro/era/japan/gengou/resource/validator.rb +347 -0
  58. data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +1870 -0
  59. data/lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml +810 -0
  60. data/lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml +50 -0
  61. data/lib/zakuro/era/japan/gengou/resource.rb +33 -0
  62. data/lib/zakuro/era/japan/gengou.rb +26 -80
  63. data/lib/zakuro/era/japan/version.rb +151 -0
  64. data/lib/zakuro/era/{western.rb → western/calendar.rb} +9 -9
  65. data/lib/zakuro/exception/case/pattern.rb +35 -0
  66. data/lib/zakuro/exception/case/preset.rb +51 -0
  67. data/lib/zakuro/exception/case/template.rb +48 -0
  68. data/lib/zakuro/exception/cause.rb +28 -0
  69. data/lib/zakuro/exception/exception.rb +37 -0
  70. data/lib/zakuro/exception/zakuro_error.rb +28 -0
  71. data/lib/zakuro/gateway/locale/date.rb +127 -0
  72. data/lib/zakuro/gateway/locale/range.rb +67 -0
  73. data/lib/zakuro/gateway/range.rb +99 -0
  74. data/lib/zakuro/gateway/single.rb +70 -0
  75. data/lib/zakuro/merchant.rb +15 -4
  76. data/lib/zakuro/operation/month/parser.rb +10 -10
  77. data/lib/zakuro/operation/month/type.rb +32 -32
  78. data/lib/zakuro/operation/month/validator.rb +51 -51
  79. data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
  80. data/lib/zakuro/output/logger.rb +17 -3
  81. data/lib/zakuro/output/response.rb +5 -5
  82. data/lib/zakuro/result/data/day.rb +43 -0
  83. data/lib/zakuro/result/data/gengou.rb +35 -0
  84. data/lib/zakuro/result/data/month.rb +63 -0
  85. data/lib/zakuro/result/data/single_day.rb +48 -0
  86. data/lib/zakuro/result/data/solar_term.rb +35 -0
  87. data/lib/zakuro/result/data/year.rb +45 -0
  88. data/lib/zakuro/result/operation/month/annotation.rb +40 -0
  89. data/lib/zakuro/result/operation/month/bundle.rb +36 -0
  90. data/lib/zakuro/result/operation/month/history.rb +54 -0
  91. data/lib/zakuro/result/operation/operation.rb +44 -0
  92. data/lib/zakuro/result/result.rb +21 -2
  93. data/lib/zakuro/tools/typeconv.rb +38 -0
  94. data/lib/zakuro/tools/typeof.rb +4 -1
  95. data/lib/zakuro/version/context.rb +24 -3
  96. data/lib/zakuro/version/daien/daien.rb +1 -26
  97. data/lib/zakuro/version/genka/genka.rb +1 -26
  98. data/lib/zakuro/version/gihou/gihou.rb +1 -30
  99. data/lib/zakuro/version/gregorio/gregorio.rb +1 -9
  100. data/lib/zakuro/version/houryaku/houryaku.rb +1 -9
  101. data/lib/zakuro/version/joukyou/joukyou.rb +1 -9
  102. data/lib/zakuro/version/kansei/kansei.rb +1 -9
  103. data/lib/zakuro/version/senmyou/README.md +11 -7
  104. data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
  105. data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
  106. data/zakuro.gemspec +1 -3
  107. metadata +74 -22
  108. data/lib/zakuro/calculation/base/multi_gengou.rb +0 -101
  109. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +0 -218
  110. data/lib/zakuro/calculation/range/full_range.rb +0 -210
  111. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
  112. data/lib/zakuro/calculation/specifier/single_day.rb +0 -109
  113. data/lib/zakuro/era/japan/gengou/parser.rb +0 -167
  114. data/lib/zakuro/era/japan/gengou/type.rb +0 -178
  115. data/lib/zakuro/era/japan/gengou/validator.rb +0 -236
  116. data/lib/zakuro/era/japan/reki.rb +0 -91
  117. data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +0 -1121
  118. data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +0 -485
  119. data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +0 -28
  120. data/lib/zakuro/result/data.rb +0 -187
  121. data/lib/zakuro/result/operation.rb +0 -114
  122. data/lib/zakuro/version/abstract_version.rb +0 -29
  123. data/lib/zakuro/version.rb +0 -7
  124. data/lib/zakuro/version_factory.rb +0 -59
@@ -1,36 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../abstract_version'
4
-
5
3
  # :nodoc:
6
4
  module Zakuro
7
5
  #
8
6
  # Genka 元嘉暦
9
7
  #
10
8
  module Genka
11
- #
12
- # Gateway アクセサメソッド群
13
- #
14
- class Gateway < AbstractVersion
15
- # @return [True] リリースあり
16
- RELEASE = true
17
-
18
- # @return [String] 暦クラス名
19
- VERSION_NAME = 'Genka'
20
-
21
- #
22
- # 西暦日から和暦日に変換する
23
- #
24
- # @param [Date] western_date 西暦日
25
- #
26
- # @return [Result::Single] 和暦日
27
- #
28
- def self.to_japan_date(western_date:)
29
- date = Western::Calendar.create(date: western_date)
30
-
31
- context = Context.new(version_name: VERSION_NAME)
32
- Calculation::Summary::Single.get(context: context, date: date)
33
- end
34
- end
9
+ # none
35
10
  end
36
11
  end
@@ -1,40 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'date'
4
- require_relative '../../era/western'
5
- require_relative '../abstract_version'
6
- require_relative '../context'
7
- require_relative '../../calculation/summary/single'
8
-
9
3
  # :nodoc:
10
4
  module Zakuro
11
5
  #
12
6
  # Gihou 儀鳳暦
13
7
  #
14
8
  module Gihou
15
- #
16
- # Gateway アクセサメソッド群
17
- #
18
- class Gateway < AbstractVersion
19
- # @return [True] リリースあり
20
- RELEASE = true
21
-
22
- # @return [String] 暦クラス名
23
- VERSION_NAME = 'Gihou'
24
-
25
- #
26
- # 西暦日から和暦日に変換する
27
- #
28
- # @param [Date] western_date 西暦日
29
- #
30
- # @return [Result::Single] 和暦日
31
- #
32
- def self.to_japan_date(western_date:)
33
- date = Western::Calendar.create(date: western_date)
34
-
35
- context = Context.new(version_name: VERSION_NAME)
36
- Calculation::Summary::Single.get(context: context, date: date)
37
- end
38
- end
9
+ # none
39
10
  end
40
11
  end
@@ -1,19 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../abstract_version'
4
-
5
3
  # :nodoc:
6
4
  module Zakuro
7
5
  #
8
6
  # Gregorio グレゴリオ暦
9
7
  #
10
8
  module Gregorio
11
- #
12
- # Gateway アクセサメソッド群
13
- #
14
- class Gateway < AbstractVersion
15
- # @return [False] リリースなし
16
- RELEASE = false
17
- end
9
+ # none
18
10
  end
19
11
  end
@@ -1,19 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../abstract_version'
4
-
5
3
  # :nodoc:
6
4
  module Zakuro
7
5
  #
8
6
  # Houryaku 宝暦暦
9
7
  #
10
8
  module Houryaku
11
- #
12
- # Gateway アクセサメソッド群
13
- #
14
- class Gateway < AbstractVersion
15
- # @return [False] リリースなし
16
- RELEASE = false
17
- end
9
+ # none
18
10
  end
19
11
  end
@@ -1,19 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../abstract_version'
4
-
5
3
  # :nodoc:
6
4
  module Zakuro
7
5
  #
8
6
  # Joukyou 貞享暦
9
7
  #
10
8
  module Joukyou
11
- #
12
- # Gateway アクセサメソッド群
13
- #
14
- class Gateway < AbstractVersion
15
- # @return [False] リリースなし
16
- RELEASE = false
17
- end
9
+ # none
18
10
  end
19
11
  end
@@ -1,19 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../abstract_version'
4
-
5
3
  # :nodoc:
6
4
  module Zakuro
7
5
  #
8
6
  # Kansei 寛政暦
9
7
  #
10
8
  module Kansei
11
- #
12
- # Gateway アクセサメソッド群
13
- #
14
- class Gateway < AbstractVersion
15
- # @return [False] リリースなし
16
- RELEASE = false
17
- end
9
+ # none
18
10
  end
19
11
  end
@@ -94,21 +94,25 @@
94
94
 
95
95
  計算の多くはそれぞれの暦に依存するが、まずは共通の計算部分を列挙する
96
96
 
97
- ### ある元号の2年目以降について
97
+ ### 元号の求め方
98
98
 
99
- 各元号の1年(元年)の始まりは固定値のため、西暦にて開始日を持つ(例: 正慶1年1月1日 = 1332/01/28)
99
+ 元慶(877-6-1 885-3-10)をもとに考える
100
100
 
101
- 日本の旧暦(太陰太陽暦)において、元号は1月1日を境に改元または継続する
101
+ 元号開始年が存在する元号年(877)から、次の元号の開始年(885) + 1 までを和暦計算する。これをAとする
102
102
 
103
- NOTE: これは『日本暦日原典』をベースにした場合であり、多くの場合、実際の改元は1月1日ではない [返却される元号が実際の存在期間と一致しない](https://github.com/pldb/zakuro/issues/3)
103
+ 元号のはじまりは固定値のため、西暦開始日と、それに対応する和暦開始日を持つ(例: 元慶01年0416日 = 877-6-1
104
104
 
105
- ここで問題となるのは、元号2年目以降はその前年までの計算結果が必要になることである
105
+ この和暦開始日は必ずAの1年目に存在するため、1年目の和暦日を特定し、その日と西暦開始日を関連付ける
106
106
 
107
- 西暦(太陽暦)のように1年あたりの日数は一定しない
107
+ もし元慶2年以降を計算したい場合は、Aの西暦開始日から該当年月日までを加算で求める
108
+
109
+ 具体的には、和暦上の月の大小(29日 or 30日)を用いた加算となる
110
+
111
+ 念のため補足するが、西暦(太陽暦)のように1年あたりの日数は一定しない
108
112
 
109
113
  平年(353/354/355/356)または閏年(383/384/385)のパターンがあり、月の大小(29/30)や閏月(中気のない月)の有無で変動する
110
114
 
111
- この日数を求めることで、初めて2年目の開始日が求められる(1332/01/28 + 355日 = 1333/1/17 = 正慶2年1月1日)
115
+ したがって、2年目以降を加算なしに特定することはできない
112
116
 
113
117
  ### 南北朝について
114
118
 
@@ -1,40 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'date'
4
- require_relative '../../era/western'
5
- require_relative '../abstract_version'
6
- require_relative '../context'
7
- require_relative '../../calculation/summary/single'
8
-
9
3
  # :nodoc:
10
4
  module Zakuro
11
5
  #
12
6
  # Senmyou 宣明暦
13
7
  #
14
8
  module Senmyou
15
- #
16
- # Gateway アクセサメソッド群
17
- #
18
- class Gateway < AbstractVersion
19
- # @return [True] リリースあり
20
- RELEASE = true
21
-
22
- # @return [String] 暦クラス名
23
- VERSION_NAME = 'Senmyou'
24
-
25
- #
26
- # 西暦日から和暦日に変換する
27
- #
28
- # @param [Date] western_date 西暦日
29
- #
30
- # @return [Result::Single] 和暦日
31
- #
32
- def self.to_japan_date(western_date:)
33
- date = Western::Calendar.create(date: western_date)
34
-
35
- context = Context.new(version_name: VERSION_NAME)
36
- Calculation::Summary::Single.get(context: context, date: date)
37
- end
38
- end
9
+ # none
39
10
  end
40
11
  end
@@ -1,19 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../abstract_version'
4
-
5
3
  # :nodoc:
6
4
  module Zakuro
7
5
  #
8
6
  # Tenpou 天保暦
9
7
  #
10
8
  module Tenpou
11
- #
12
- # Gateway アクセサメソッド群
13
- #
14
- class Gateway < AbstractVersion
15
- # @return [False] リリースなし
16
- RELEASE = false
17
- end
9
+ # none
18
10
  end
19
11
  end
data/zakuro.gemspec CHANGED
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/zakuro/version'
4
-
5
3
  Gem::Specification.new do |spec|
6
4
  spec.name = 'zakuro'
7
- spec.version = Zakuro::VERSION
5
+ spec.version = File.read(File.expand_path('./VERSION', __dir__)).strip
8
6
  spec.authors = ['pldb']
9
7
  spec.email = ['pldb.github@gmail.com']
10
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zakuro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pldb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-07 00:00:00.000000000 Z
11
+ date: 2022-04-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: mainly lunar solar calendar
14
14
  email:
@@ -26,6 +26,7 @@ files:
26
26
  - Makefile
27
27
  - README.md
28
28
  - Rakefile
29
+ - VERSION
29
30
  - bin/console
30
31
  - bin/setup
31
32
  - doc/gengou.md
@@ -40,43 +41,88 @@ files:
40
41
  - images/各月の求め方.png
41
42
  - images/太陽と月.png
42
43
  - lib/zakuro.rb
43
- - lib/zakuro/calculation/base/multi_gengou.rb
44
- - lib/zakuro/calculation/base/multi_gengou_roller.rb
44
+ - lib/zakuro/calculation/base/gengou.rb
45
+ - lib/zakuro/calculation/base/linear_gengou.rb
45
46
  - lib/zakuro/calculation/base/operated_year.rb
46
47
  - lib/zakuro/calculation/base/year.rb
47
48
  - lib/zakuro/calculation/cycle/abstract_remainder.rb
48
49
  - lib/zakuro/calculation/cycle/abstract_solar_term.rb
49
50
  - lib/zakuro/calculation/cycle/zodiac.rb
51
+ - lib/zakuro/calculation/era/gengou/abstract_scroll.rb
52
+ - lib/zakuro/calculation/era/gengou/dated_scroll.rb
53
+ - lib/zakuro/calculation/era/gengou/internal/connector.rb
54
+ - lib/zakuro/calculation/era/gengou/internal/counter.rb
55
+ - lib/zakuro/calculation/era/gengou/internal/publisher.rb
56
+ - lib/zakuro/calculation/era/gengou/internal/reserve.rb
57
+ - lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb
58
+ - lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb
59
+ - lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb
60
+ - lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb
61
+ - lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb
62
+ - lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb
63
+ - lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb
64
+ - lib/zakuro/calculation/era/gengou/named_scroll.rb
65
+ - lib/zakuro/calculation/era/version/internal/crawler.rb
66
+ - lib/zakuro/calculation/era/version/internal/range.rb
67
+ - lib/zakuro/calculation/era/version/version.rb
50
68
  - lib/zakuro/calculation/monthly/abstract_lunar_phase.rb
51
69
  - lib/zakuro/calculation/monthly/first_day.rb
52
70
  - lib/zakuro/calculation/monthly/initialized_month.rb
53
71
  - lib/zakuro/calculation/monthly/month.rb
54
72
  - lib/zakuro/calculation/monthly/month_label.rb
55
73
  - lib/zakuro/calculation/monthly/operated_month.rb
56
- - lib/zakuro/calculation/range/full_range.rb
74
+ - lib/zakuro/calculation/range/abstract_full_range.rb
75
+ - lib/zakuro/calculation/range/abstract_operation_range.rb
76
+ - lib/zakuro/calculation/range/dated_full_range.rb
77
+ - lib/zakuro/calculation/range/dated_operation_range.rb
57
78
  - lib/zakuro/calculation/range/medieval_annual_range.rb
58
- - lib/zakuro/calculation/range/operated_range.rb
79
+ - lib/zakuro/calculation/range/named_full_range.rb
80
+ - lib/zakuro/calculation/range/named_operation_range.rb
59
81
  - lib/zakuro/calculation/range/operated_solar_terms.rb
60
- - lib/zakuro/calculation/range/transfer/western_date_allocation.rb
82
+ - lib/zakuro/calculation/range/transfer/gengou_scroller.rb
61
83
  - lib/zakuro/calculation/range/transfer/year_boundary.rb
62
- - lib/zakuro/calculation/specifier/single_day.rb
63
84
  - lib/zakuro/calculation/stella/lunar/abstract_location.rb
64
85
  - lib/zakuro/calculation/stella/lunar/choukei_value.rb
65
86
  - lib/zakuro/calculation/stella/solar/abstract_average.rb
66
87
  - lib/zakuro/calculation/stella/solar/abstract_location.rb
67
88
  - lib/zakuro/calculation/stella/solar/choukei_value.rb
68
- - lib/zakuro/calculation/summary/single.rb
89
+ - lib/zakuro/calculation/summary/internal/month.rb
90
+ - lib/zakuro/calculation/summary/internal/operation.rb
91
+ - lib/zakuro/calculation/summary/japan/range.rb
92
+ - lib/zakuro/calculation/summary/japan/single.rb
93
+ - lib/zakuro/calculation/summary/japan/specifier/single_day.rb
94
+ - lib/zakuro/calculation/summary/western/range.rb
95
+ - lib/zakuro/calculation/summary/western/single.rb
96
+ - lib/zakuro/calculation/summary/western/specifier/multiple_day.rb
97
+ - lib/zakuro/calculation/summary/western/specifier/single_day.rb
69
98
  - lib/zakuro/calculation/type/old_float.rb
70
99
  - lib/zakuro/condition.rb
100
+ - lib/zakuro/era/japan/calendar.rb
71
101
  - lib/zakuro/era/japan/gengou.rb
72
- - lib/zakuro/era/japan/gengou/parser.rb
73
- - lib/zakuro/era/japan/gengou/type.rb
74
- - lib/zakuro/era/japan/gengou/validator.rb
75
- - lib/zakuro/era/japan/reki.rb
76
- - lib/zakuro/era/japan/yaml/set-001-until-south.yaml
77
- - lib/zakuro/era/japan/yaml/set-002-from-north.yaml
78
- - lib/zakuro/era/japan/yaml/set-003-modern.yaml
79
- - lib/zakuro/era/western.rb
102
+ - lib/zakuro/era/japan/gengou/alignment.rb
103
+ - lib/zakuro/era/japan/gengou/alignment/aligner.rb
104
+ - lib/zakuro/era/japan/gengou/alignment/division.rb
105
+ - lib/zakuro/era/japan/gengou/alignment/line.rb
106
+ - lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb
107
+ - lib/zakuro/era/japan/gengou/resource.rb
108
+ - lib/zakuro/era/japan/gengou/resource/parser.rb
109
+ - lib/zakuro/era/japan/gengou/resource/type.rb
110
+ - lib/zakuro/era/japan/gengou/resource/validator.rb
111
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml
112
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml
113
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml
114
+ - lib/zakuro/era/japan/version.rb
115
+ - lib/zakuro/era/western/calendar.rb
116
+ - lib/zakuro/exception/case/pattern.rb
117
+ - lib/zakuro/exception/case/preset.rb
118
+ - lib/zakuro/exception/case/template.rb
119
+ - lib/zakuro/exception/cause.rb
120
+ - lib/zakuro/exception/exception.rb
121
+ - lib/zakuro/exception/zakuro_error.rb
122
+ - lib/zakuro/gateway/locale/date.rb
123
+ - lib/zakuro/gateway/locale/range.rb
124
+ - lib/zakuro/gateway/range.rb
125
+ - lib/zakuro/gateway/single.rb
80
126
  - lib/zakuro/merchant.rb
81
127
  - lib/zakuro/operation/month/parser.rb
82
128
  - lib/zakuro/operation/month/type.rb
@@ -87,13 +133,20 @@ files:
87
133
  - lib/zakuro/output/logger.rb
88
134
  - lib/zakuro/output/response.rb
89
135
  - lib/zakuro/result/core.rb
90
- - lib/zakuro/result/data.rb
91
- - lib/zakuro/result/operation.rb
136
+ - lib/zakuro/result/data/day.rb
137
+ - lib/zakuro/result/data/gengou.rb
138
+ - lib/zakuro/result/data/month.rb
139
+ - lib/zakuro/result/data/single_day.rb
140
+ - lib/zakuro/result/data/solar_term.rb
141
+ - lib/zakuro/result/data/year.rb
142
+ - lib/zakuro/result/operation/month/annotation.rb
143
+ - lib/zakuro/result/operation/month/bundle.rb
144
+ - lib/zakuro/result/operation/month/history.rb
145
+ - lib/zakuro/result/operation/operation.rb
92
146
  - lib/zakuro/result/result.rb
93
147
  - lib/zakuro/tools/stringifier.rb
148
+ - lib/zakuro/tools/typeconv.rb
94
149
  - lib/zakuro/tools/typeof.rb
95
- - lib/zakuro/version.rb
96
- - lib/zakuro/version/abstract_version.rb
97
150
  - lib/zakuro/version/context.rb
98
151
  - lib/zakuro/version/daien/const/number.rb
99
152
  - lib/zakuro/version/daien/const/remainder.rb
@@ -169,7 +222,6 @@ files:
169
222
  - lib/zakuro/version/senmyou/stella/solar/value.rb
170
223
  - lib/zakuro/version/tenpou/tenpou.rb
171
224
  - lib/zakuro/version/version_class_resolver.rb
172
- - lib/zakuro/version_factory.rb
173
225
  - zakuro.gemspec
174
226
  homepage: https://github.com/pldb/zakuro
175
227
  licenses:
@@ -1,101 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../era/japan/gengou'
4
- require_relative '../../era/western'
5
-
6
- # :nodoc:
7
- module Zakuro
8
- # :nodoc:
9
- module Calculation
10
- # :nodoc:
11
- module Base
12
- #
13
- # MultiGengou 複数元号
14
- #
15
- class MultiGengou
16
- # @return [Japan::Gengou] 元号(1行目)
17
- attr_reader :first_line
18
- # @return [Japan::Gengou] 元号(2行目)
19
- attr_reader :second_line
20
- # @return [Western::Calendar] 元旦
21
- attr_reader :new_year_date
22
-
23
- def initialize(first_line: Japan::Gengou.new, second_line: Japan::Gengou.new,
24
- new_year_date: Western::Calendar.new)
25
- @first_line = first_line
26
- @second_line = second_line
27
- @new_year_date = new_year_date
28
- end
29
-
30
- # :reek:TooManyStatements { max_statements: 7 }
31
-
32
- #
33
- # 改元する
34
- #
35
- # @param [Japan::Gengou] first_line 元号(1行目)
36
- # @param [Japan::Gengou] second_line 元号(2行目)
37
- #
38
- # @return [MultiGengou] 自身
39
- #
40
- def transfer(first_line: Japan::Gengou.new, second_line: Japan::Gengou.new)
41
- cloned_first_line = first_line.clone
42
- cloned_second_line = second_line.clone
43
-
44
- if integrated?(first_line: cloned_first_line, second_line: cloned_second_line)
45
- @first_line = @second_line.clone
46
- @second_line = cloned_second_line
47
- end
48
-
49
- @first_line = cloned_first_line if @first_line.name != first_line.name
50
- @second_line = cloned_second_line if @second_line.name != second_line.name
51
-
52
- self
53
- end
54
-
55
- #
56
- # 次年にする
57
- #
58
- # @param [Japan::Gengou] first_line 元号(1行目)
59
- # @param [Japan::Gengou] second_line 元号(2行目)
60
- #
61
- # @return [MultiGengou] 自身
62
- #
63
- def next_year
64
- @first_line.next_year
65
- @second_line.next_year
66
-
67
- self
68
- end
69
-
70
- #
71
- # ディープコピー
72
- #
73
- # @param [MultiGengou] obj 自身
74
- #
75
- def initialize_copy(obj)
76
- @first_line = obj.first_line.clone
77
- @second_line = obj.second_line.clone
78
- end
79
-
80
- private
81
-
82
- #
83
- # 複数元号を統一するかどうか
84
- #
85
- # @param [Japan::Gengou] first_line 元号(1行目)
86
- # @param [Japan::Gengou] second_line 元号(2行目)
87
- #
88
- # @return [True] 統一する
89
- # @return [False] 統一しない
90
- #
91
- def integrated?(first_line: Japan::Gengou.new, second_line: Japan::Gengou.new)
92
- return false if @second_line.name != first_line.name
93
-
94
- return false unless second_line.invalid?
95
-
96
- true
97
- end
98
- end
99
- end
100
- end
101
- end