zakuro 0.4.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -3
  3. data/VERSION +1 -0
  4. data/doc/operation/csv/month.csv +21 -0
  5. data/doc/operation/operation.xlsx +0 -0
  6. data/lib/zakuro/calculation/base/gengou.rb +82 -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/cycle/abstract_remainder.rb +0 -13
  11. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +107 -0
  12. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +214 -0
  13. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +104 -0
  14. data/lib/zakuro/calculation/era/gengou/internal/reserve/list.rb +244 -0
  15. data/lib/zakuro/calculation/era/gengou/internal/reserve/range.rb +193 -0
  16. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +42 -0
  17. data/lib/zakuro/calculation/era/gengou/scroll.rb +211 -0
  18. data/lib/zakuro/calculation/era/version/internal/crawler.rb +51 -0
  19. data/lib/zakuro/calculation/era/version/internal/range.rb +39 -0
  20. data/lib/zakuro/calculation/era/version/version.rb +24 -0
  21. data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
  22. data/lib/zakuro/calculation/monthly/month.rb +49 -2
  23. data/lib/zakuro/calculation/monthly/operated_month.rb +2 -2
  24. data/lib/zakuro/calculation/range/full_range.rb +68 -107
  25. data/lib/zakuro/calculation/range/operated_range.rb +13 -9
  26. data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -17
  27. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +54 -0
  28. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +25 -21
  29. data/lib/zakuro/calculation/specifier/internal/month.rb +84 -0
  30. data/lib/zakuro/calculation/specifier/multiple_day.rb +162 -0
  31. data/lib/zakuro/calculation/specifier/single_day.rb +15 -37
  32. data/lib/zakuro/calculation/summary/internal/operation.rb +98 -0
  33. data/lib/zakuro/calculation/summary/range.rb +120 -0
  34. data/lib/zakuro/calculation/summary/single.rb +45 -64
  35. data/lib/zakuro/condition.rb +14 -0
  36. data/lib/zakuro/era/japan/calendar.rb +133 -0
  37. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +106 -0
  38. data/lib/zakuro/era/japan/gengou/alignment/division.rb +165 -0
  39. data/lib/zakuro/era/japan/gengou/alignment/line.rb +156 -0
  40. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +184 -0
  41. data/lib/zakuro/era/japan/gengou/alignment.rb +42 -0
  42. data/lib/zakuro/era/japan/gengou/resource/parser.rb +242 -0
  43. data/lib/zakuro/era/japan/gengou/resource/type.rb +292 -0
  44. data/lib/zakuro/era/japan/gengou/resource/validator.rb +346 -0
  45. data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +1870 -0
  46. data/lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml +810 -0
  47. data/lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml +50 -0
  48. data/lib/zakuro/era/japan/gengou/resource.rb +32 -0
  49. data/lib/zakuro/era/japan/gengou.rb +35 -74
  50. data/lib/zakuro/era/japan/version.rb +151 -0
  51. data/lib/zakuro/era/{western.rb → western/calendar.rb} +0 -0
  52. data/lib/zakuro/merchant.rb +50 -3
  53. data/lib/zakuro/operation/month/parser.rb +1 -1
  54. data/lib/zakuro/operation/month/type.rb +1 -1
  55. data/lib/zakuro/operation/month/validator.rb +2 -2
  56. data/lib/zakuro/operation/yaml/month.yaml +672 -0
  57. data/lib/zakuro/output/response.rb +5 -5
  58. data/lib/zakuro/result/result.rb +17 -0
  59. data/lib/zakuro/tools/typeconv.rb +38 -0
  60. data/lib/zakuro/tools/typeof.rb +4 -1
  61. data/lib/zakuro/version/context.rb +24 -3
  62. data/lib/zakuro/version/daien/cycle/remainder.rb +26 -0
  63. data/lib/zakuro/version/daien/daien.rb +1 -26
  64. data/lib/zakuro/version/daien/stella/solar/average.rb +2 -2
  65. data/lib/zakuro/version/genka/const/number.rb +43 -0
  66. data/lib/zakuro/version/genka/const/remainder.rb +33 -0
  67. data/lib/zakuro/version/genka/cycle/remainder.rb +92 -0
  68. data/lib/zakuro/version/genka/cycle/solar_term.rb +34 -0
  69. data/lib/zakuro/version/genka/genka.rb +1 -9
  70. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +95 -0
  71. data/lib/zakuro/version/genka/range/annual_range.rb +77 -0
  72. data/lib/zakuro/version/genka/stella/origin/first_term.rb +55 -0
  73. data/lib/zakuro/version/genka/stella/origin/january.rb +49 -0
  74. data/lib/zakuro/version/genka/stella/solar/average.rb +41 -0
  75. data/lib/zakuro/version/gihou/cycle/remainder.rb +26 -0
  76. data/lib/zakuro/version/gihou/gihou.rb +1 -30
  77. data/lib/zakuro/version/gihou/stella/solar/average.rb +2 -2
  78. data/lib/zakuro/version/gregorio/gregorio.rb +1 -9
  79. data/lib/zakuro/version/houryaku/houryaku.rb +1 -9
  80. data/lib/zakuro/version/joukyou/joukyou.rb +1 -9
  81. data/lib/zakuro/version/kansei/kansei.rb +1 -9
  82. data/lib/zakuro/version/senmyou/README.md +11 -7
  83. data/lib/zakuro/version/senmyou/cycle/remainder.rb +26 -0
  84. data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
  85. data/lib/zakuro/version/senmyou/stella/solar/average.rb +2 -2
  86. data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
  87. data/lib/zakuro/version/version_class_resolver.rb +4 -0
  88. data/zakuro.gemspec +1 -3
  89. metadata +45 -16
  90. data/lib/zakuro/calculation/base/multi_gengou.rb +0 -101
  91. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +0 -218
  92. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
  93. data/lib/zakuro/era/japan/gengou/parser.rb +0 -167
  94. data/lib/zakuro/era/japan/gengou/type.rb +0 -178
  95. data/lib/zakuro/era/japan/gengou/validator.rb +0 -236
  96. data/lib/zakuro/era/japan/reki.rb +0 -91
  97. data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +0 -1121
  98. data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +0 -485
  99. data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +0 -28
  100. data/lib/zakuro/version/abstract_version.rb +0 -29
  101. data/lib/zakuro/version.rb +0 -7
  102. data/lib/zakuro/version_factory.rb +0 -59
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../../calculation/stella/solar/abstract_average'
4
+
5
+ require_relative '../../const/remainder'
6
+
7
+ require_relative '../../cycle/solar_term'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Genka
13
+ # :nodoc:
14
+ module Solar
15
+ #
16
+ # Average 平気(太陽軌道平均)
17
+ #
18
+ class Average < Calculation::Solar::AbstractAverage
19
+ #
20
+ # 初期化
21
+ #
22
+ # @param [Integer] western_year 西暦年
23
+ #
24
+ def initialize(solar_term:)
25
+ super(solar_term: solar_term)
26
+ end
27
+
28
+ #
29
+ # 冬至から数えた1年データの月ごとに二十四節気を割り当てる
30
+ #
31
+ # @param [Array<Month>] annual_range 1年データ
32
+ #
33
+ # @return [Array<Month>] 1年データ
34
+ #
35
+ def set(annual_range:)
36
+ super(annual_range: annual_range)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -29,6 +29,19 @@ module Zakuro
29
29
  super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
30
30
  day: day, minute: minute, second: second, total: total)
31
31
  end
32
+
33
+ #
34
+ # 特定の文字フォーマットにして出力する
35
+ #
36
+ # @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
37
+ #
38
+ # @return [String] フォーマットした結果
39
+ #
40
+ def format(form: '%d-%d')
41
+ return '' if invalid?
42
+
43
+ super(form, @day, @minute, @second)
44
+ end
32
45
  end
33
46
 
34
47
  #
@@ -50,6 +63,19 @@ module Zakuro
50
63
  super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
51
64
  day: day, minute: minute, second: second, total: total)
52
65
  end
66
+
67
+ #
68
+ # 特定の文字フォーマットにして出力する
69
+ #
70
+ # @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
71
+ #
72
+ # @return [String] フォーマットした結果
73
+ #
74
+ def format(form: '%d-%d')
75
+ return '' if invalid?
76
+
77
+ super(form, @day, @minute, @second)
78
+ end
53
79
  end
54
80
  end
55
81
  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
@@ -55,7 +55,7 @@ module Zakuro
55
55
  # 二十四節気(冬至)
56
56
  solar_term = Cycle::SolarTerm.new(index: 0, remainder: winter_solstice)
57
57
 
58
- first_solar_term_index = Average.calc_fist_solar_term_index(western_year: western_year)
58
+ first_solar_term_index = Average.calc_first_solar_term_index(western_year: western_year)
59
59
 
60
60
  # 対象の二十四節気まで戻す
61
61
  solar_term.prev_by_index(first_solar_term_index)
@@ -77,7 +77,7 @@ module Zakuro
77
77
  #
78
78
  # @return [Integer] 二十四節気番号
79
79
  #
80
- def self.calc_fist_solar_term_index(western_year:)
80
+ def self.calc_first_solar_term_index(western_year:)
81
81
  # 天正閏余
82
82
  lunar_age = Origin::LunarAge.get(western_year: western_year)
83
83
 
@@ -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
 
@@ -29,6 +29,19 @@ module Zakuro
29
29
  super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
30
30
  day: day, minute: minute, second: second, total: total)
31
31
  end
32
+
33
+ #
34
+ # 特定の文字フォーマットにして出力する
35
+ #
36
+ # @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
37
+ #
38
+ # @return [String] フォーマットした結果
39
+ #
40
+ def format(form: '%d-%d')
41
+ return '' if invalid?
42
+
43
+ super(form, @day, @minute, @second)
44
+ end
32
45
  end
33
46
 
34
47
  #
@@ -50,6 +63,19 @@ module Zakuro
50
63
  super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
51
64
  day: day, minute: minute, second: second, total: total)
52
65
  end
66
+
67
+ #
68
+ # 特定の文字フォーマットにして出力する
69
+ #
70
+ # @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
71
+ #
72
+ # @return [String] フォーマットした結果
73
+ #
74
+ def format(form: '%d-%d')
75
+ return '' if invalid?
76
+
77
+ super(form, @day, @minute, @second)
78
+ end
53
79
  end
54
80
  end
55
81
  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
  # 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
@@ -55,7 +55,7 @@ module Zakuro
55
55
  # 二十四節気(冬至)
56
56
  solar_term = Cycle::SolarTerm.new(index: 0, remainder: winter_solstice)
57
57
 
58
- first_solar_term_index = Average.calc_fist_solar_term_index(western_year: western_year)
58
+ first_solar_term_index = Average.calc_first_solar_term_index(western_year: western_year)
59
59
 
60
60
  # 対象の二十四節気まで戻す
61
61
  solar_term.prev_by_index(first_solar_term_index)
@@ -77,7 +77,7 @@ module Zakuro
77
77
  #
78
78
  # @return [Integer] 二十四節気番号
79
79
  #
80
- def self.calc_fist_solar_term_index(western_year:)
80
+ def self.calc_first_solar_term_index(western_year:)
81
81
  # 天正閏余
82
82
  lunar_age = Origin::LunarAge.get(western_year: western_year)
83
83
 
@@ -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
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative './genka/cycle/remainder'
4
+ require_relative './genka/cycle/solar_term'
5
+ require_relative './genka/range/annual_range'
6
+
3
7
  require_relative './gihou/cycle/remainder'
4
8
  require_relative './gihou/cycle/solar_term'
5
9
  require_relative './gihou/range/annual_range'
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.4.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pldb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-02 00:00:00.000000000 Z
11
+ date: 2022-03-02 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,13 +41,23 @@ 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/internal/connector.rb
52
+ - lib/zakuro/calculation/era/gengou/internal/counter.rb
53
+ - lib/zakuro/calculation/era/gengou/internal/publisher.rb
54
+ - lib/zakuro/calculation/era/gengou/internal/reserve.rb
55
+ - lib/zakuro/calculation/era/gengou/internal/reserve/list.rb
56
+ - lib/zakuro/calculation/era/gengou/internal/reserve/range.rb
57
+ - lib/zakuro/calculation/era/gengou/scroll.rb
58
+ - lib/zakuro/calculation/era/version/internal/crawler.rb
59
+ - lib/zakuro/calculation/era/version/internal/range.rb
60
+ - lib/zakuro/calculation/era/version/version.rb
50
61
  - lib/zakuro/calculation/monthly/abstract_lunar_phase.rb
51
62
  - lib/zakuro/calculation/monthly/first_day.rb
52
63
  - lib/zakuro/calculation/monthly/initialized_month.rb
@@ -57,26 +68,37 @@ files:
57
68
  - lib/zakuro/calculation/range/medieval_annual_range.rb
58
69
  - lib/zakuro/calculation/range/operated_range.rb
59
70
  - lib/zakuro/calculation/range/operated_solar_terms.rb
60
- - lib/zakuro/calculation/range/transfer/western_date_allocation.rb
71
+ - lib/zakuro/calculation/range/transfer/gengou_scroller.rb
61
72
  - lib/zakuro/calculation/range/transfer/year_boundary.rb
73
+ - lib/zakuro/calculation/specifier/internal/month.rb
74
+ - lib/zakuro/calculation/specifier/multiple_day.rb
62
75
  - lib/zakuro/calculation/specifier/single_day.rb
63
76
  - lib/zakuro/calculation/stella/lunar/abstract_location.rb
64
77
  - lib/zakuro/calculation/stella/lunar/choukei_value.rb
65
78
  - lib/zakuro/calculation/stella/solar/abstract_average.rb
66
79
  - lib/zakuro/calculation/stella/solar/abstract_location.rb
67
80
  - lib/zakuro/calculation/stella/solar/choukei_value.rb
81
+ - lib/zakuro/calculation/summary/internal/operation.rb
82
+ - lib/zakuro/calculation/summary/range.rb
68
83
  - lib/zakuro/calculation/summary/single.rb
69
84
  - lib/zakuro/calculation/type/old_float.rb
70
85
  - lib/zakuro/condition.rb
86
+ - lib/zakuro/era/japan/calendar.rb
71
87
  - 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
88
+ - lib/zakuro/era/japan/gengou/alignment.rb
89
+ - lib/zakuro/era/japan/gengou/alignment/aligner.rb
90
+ - lib/zakuro/era/japan/gengou/alignment/division.rb
91
+ - lib/zakuro/era/japan/gengou/alignment/line.rb
92
+ - lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb
93
+ - lib/zakuro/era/japan/gengou/resource.rb
94
+ - lib/zakuro/era/japan/gengou/resource/parser.rb
95
+ - lib/zakuro/era/japan/gengou/resource/type.rb
96
+ - lib/zakuro/era/japan/gengou/resource/validator.rb
97
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml
98
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml
99
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml
100
+ - lib/zakuro/era/japan/version.rb
101
+ - lib/zakuro/era/western/calendar.rb
80
102
  - lib/zakuro/merchant.rb
81
103
  - lib/zakuro/operation/month/parser.rb
82
104
  - lib/zakuro/operation/month/type.rb
@@ -91,9 +113,8 @@ files:
91
113
  - lib/zakuro/result/operation.rb
92
114
  - lib/zakuro/result/result.rb
93
115
  - lib/zakuro/tools/stringifier.rb
116
+ - lib/zakuro/tools/typeconv.rb
94
117
  - lib/zakuro/tools/typeof.rb
95
- - lib/zakuro/version.rb
96
- - lib/zakuro/version/abstract_version.rb
97
118
  - lib/zakuro/version/context.rb
98
119
  - lib/zakuro/version/daien/const/number.rb
99
120
  - lib/zakuro/version/daien/const/remainder.rb
@@ -114,7 +135,16 @@ files:
114
135
  - lib/zakuro/version/daien/stella/solar/interval.rb
115
136
  - lib/zakuro/version/daien/stella/solar/location.rb
116
137
  - lib/zakuro/version/daien/stella/solar/value.rb
138
+ - lib/zakuro/version/genka/const/number.rb
139
+ - lib/zakuro/version/genka/const/remainder.rb
140
+ - lib/zakuro/version/genka/cycle/remainder.rb
141
+ - lib/zakuro/version/genka/cycle/solar_term.rb
117
142
  - lib/zakuro/version/genka/genka.rb
143
+ - lib/zakuro/version/genka/monthly/lunar_phase.rb
144
+ - lib/zakuro/version/genka/range/annual_range.rb
145
+ - lib/zakuro/version/genka/stella/origin/first_term.rb
146
+ - lib/zakuro/version/genka/stella/origin/january.rb
147
+ - lib/zakuro/version/genka/stella/solar/average.rb
118
148
  - lib/zakuro/version/gihou/const/number.rb
119
149
  - lib/zakuro/version/gihou/const/remainder.rb
120
150
  - lib/zakuro/version/gihou/cycle/remainder.rb
@@ -160,7 +190,6 @@ files:
160
190
  - lib/zakuro/version/senmyou/stella/solar/value.rb
161
191
  - lib/zakuro/version/tenpou/tenpou.rb
162
192
  - lib/zakuro/version/version_class_resolver.rb
163
- - lib/zakuro/version_factory.rb
164
193
  - zakuro.gemspec
165
194
  homepage: https://github.com/pldb/zakuro
166
195
  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