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
@@ -12,9 +12,9 @@ module Zakuro
12
12
  LEVELS = {
13
13
  none: -1,
14
14
  debug: 0,
15
- info: 1
16
- # warn : 2,
17
- # error : 3,
15
+ info: 1,
16
+ warn: 2,
17
+ error: 3
18
18
  }.freeze
19
19
 
20
20
  LEVEL = LEVELS[:none]
@@ -48,6 +48,20 @@ module Zakuro
48
48
  output('INFO', *messages)
49
49
  end
50
50
 
51
+ #
52
+ # ERRORレベルの標準出力を行う
53
+ #
54
+ # @param [Error] error 例外
55
+ # @param [String] messages メッセージ
56
+ #
57
+ def error(error, *messages)
58
+ return if LEVEL < LEVELS[:error]
59
+
60
+ output('ERROR', *messages)
61
+ output('ERROR', error.message)
62
+ output('ERROR', *error.backtrace)
63
+ end
64
+
51
65
  private
52
66
 
53
67
  #
@@ -56,7 +56,7 @@ module Zakuro
56
56
  date = param.date
57
57
  days = param.days
58
58
  Result::Data::SingleDay.new(
59
- year: save_year(year: year),
59
+ year: save_year(year: year, month: month, date: date),
60
60
  month: save_month(month: month, date: date, days: days),
61
61
  day: save_day(month: month, date: date, days: days)
62
62
  )
@@ -69,10 +69,10 @@ module Zakuro
69
69
  #
70
70
  # @return [Result::Year] 年データ
71
71
  #
72
- def self.save_year(year:)
73
- multi_gengou = year.multi_gengou
74
- first = multi_gengou.first_line
75
- second = multi_gengou.second_line
72
+ def self.save_year(year:, month:, date:)
73
+ gengou = month.gengou
74
+ first = gengou.match_first_line(date: date)
75
+ second = gengou.match_second_line(date: date)
76
76
  Result::Data::Year.new(
77
77
  first_gengou:
78
78
  Result::Data::Gengou.new(name: first.name, number: first.year),
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Zakuro
5
+ #
6
+ # Result 演算結果
7
+ #
8
+ module Result
9
+ #
10
+ # データ部
11
+ #
12
+ module Data
13
+ #
14
+ # Day 日
15
+ #
16
+ class Day
17
+ # @return [Integer] 月初日から数えた日(M月d日のdに相当)
18
+ attr_reader :number
19
+ # @return [String] 十干十二支
20
+ attr_reader :zodiac_name
21
+ # @return [String] 大余小余
22
+ attr_reader :remainder
23
+ # @return [String] 年月日
24
+ attr_reader :western_date
25
+
26
+ #
27
+ # 初期化
28
+ #
29
+ # @param [Integer] number 月初日から数えた日(M月d日のdに相当)
30
+ # @param [String] zodiac_name 十干十二支
31
+ # @param [String] remainder 大余小余
32
+ # @param [String] western_date 年月日
33
+ #
34
+ def initialize(number:, zodiac_name:, remainder:, western_date:)
35
+ @number = number
36
+ @zodiac_name = zodiac_name
37
+ @remainder = remainder
38
+ @western_date = western_date
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Zakuro
5
+ #
6
+ # Result 演算結果
7
+ #
8
+ module Result
9
+ #
10
+ # データ部
11
+ #
12
+ module Data
13
+ #
14
+ # Gengou 元号
15
+ #
16
+ class Gengou
17
+ # @return [String] 元号名
18
+ attr_reader :name
19
+ # @return [Integer] 元号年
20
+ attr_reader :number
21
+
22
+ #
23
+ # 初期化
24
+ #
25
+ # @param [String] name 元号名
26
+ # @param [Integer] number 元号年
27
+ #
28
+ def initialize(name: '', number: -1)
29
+ @name = name
30
+ @number = number
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './day'
4
+
5
+ require_relative './solar_term'
6
+
7
+ # :nodoc:
8
+ module Zakuro
9
+ #
10
+ # Result 演算結果
11
+ #
12
+ module Result
13
+ #
14
+ # データ部
15
+ #
16
+ module Data
17
+ # :reek:TooManyInstanceVariables { max_instance_variables: 6 }
18
+
19
+ #
20
+ # Month 月
21
+ #
22
+ class Month
23
+ # @return [Integer] 月順(1-12)
24
+ attr_reader :number
25
+ # @return [True] 閏月
26
+ # @return [False] 平月
27
+ attr_reader :leaped
28
+ # @return [String] 月の大小
29
+ attr_reader :days_name
30
+ # @return [Day] 月初日データ
31
+ attr_reader :first_day
32
+ # @return [SolarTerm] 二十四節気(節気)
33
+ attr_reader :odd_solar_terms
34
+ # @return [SolarTerm] 二十四節気(中気)
35
+ attr_reader :even_solar_terms
36
+
37
+ # rubocop:disable Metrics/ParameterLists
38
+ # :reek:LongParameterList { max_params: 6 }
39
+
40
+ #
41
+ # 初期化
42
+ #
43
+ # @param [Integer] number 月順(1-12)
44
+ # @param [True, False] leaped 閏月/平月
45
+ # @param [String] days_name 月の大小
46
+ # @param [Day] first_day 月初日データ
47
+ # @param [SolarTerm] odd_solar_terms 二十四節気(節気)
48
+ # @param [SolarTerm] even_solar_terms 二十四節気(中気)
49
+ #
50
+ def initialize(number:, leaped:, days_name:, first_day:,
51
+ odd_solar_terms:, even_solar_terms:)
52
+ @number = number
53
+ @leaped = leaped
54
+ @days_name = days_name
55
+ @first_day = first_day
56
+ @odd_solar_terms = odd_solar_terms
57
+ @even_solar_terms = even_solar_terms
58
+ end
59
+ # rubocop:enable Metrics/ParameterLists
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core'
4
+
5
+ require_relative 'year'
6
+
7
+ require_relative 'month'
8
+
9
+ require_relative 'day'
10
+
11
+ # :nodoc:
12
+ module Zakuro
13
+ #
14
+ # Result 演算結果
15
+ #
16
+ module Result
17
+ #
18
+ # データ部
19
+ #
20
+ module Data
21
+ #
22
+ # SingleDay 1日
23
+ #
24
+ class SingleDay < Core
25
+ # @return [Year] 年
26
+ attr_reader :year
27
+ # @return [Month] 月
28
+ attr_reader :month
29
+ # @return [Day] 日
30
+ attr_reader :day
31
+
32
+ #
33
+ # 初期化
34
+ #
35
+ # @param [Year] year 年
36
+ # @param [Month] month 月
37
+ # @param [Day] day 日
38
+ #
39
+ def initialize(year:, month:, day:)
40
+ super
41
+ @year = year
42
+ @month = month
43
+ @day = day
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Zakuro
5
+ #
6
+ # Result 演算結果
7
+ #
8
+ module Result
9
+ #
10
+ # データ部
11
+ #
12
+ module Data
13
+ #
14
+ # SolarTerm 二十四節気
15
+ #
16
+ class SolarTerm
17
+ # @return [Integer] 連番
18
+ attr_reader :index
19
+ # @return [String] 大余小余
20
+ attr_reader :remainder
21
+
22
+ #
23
+ # 初期化
24
+ #
25
+ # @param [Integer] index 連番
26
+ # @param [String] remainder 大余小余
27
+ #
28
+ def initialize(index:, remainder:)
29
+ @index = index
30
+ @remainder = remainder
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './gengou'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ #
8
+ # Result 演算結果
9
+ #
10
+ module Result
11
+ #
12
+ # データ部
13
+ #
14
+ module Data
15
+ #
16
+ # Year 年
17
+ #
18
+ class Year
19
+ # @return [Gengou] 元号(1行目)
20
+ attr_reader :first_gengou
21
+ # @return [Gengou] 元号(2行目)
22
+ attr_reader :second_gengou
23
+ # @return [String] 十干十二支
24
+ attr_reader :zodiac_name
25
+ # @return [Integer] 日数
26
+ attr_reader :total_days
27
+
28
+ #
29
+ # 初期化
30
+ #
31
+ # @param [Gengou] first_gengou 元号(1行目)
32
+ # @param [Gengou] second_gengou 元号(2行目)
33
+ # @param [String] zodiac_name 十干十二支
34
+ # @param [Integer] total_days 日数
35
+ #
36
+ def initialize(first_gengou:, second_gengou:, zodiac_name:, total_days:)
37
+ @first_gengou = first_gengou
38
+ @second_gengou = second_gengou
39
+ @zodiac_name = zodiac_name
40
+ @total_days = total_days
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc:
4
+ module Zakuro
5
+ #
6
+ # Result 演算結果
7
+ #
8
+ module Result
9
+ #
10
+ # 運用情報
11
+ #
12
+ module Operation
13
+ #
14
+ # Month 運用情報(月)
15
+ #
16
+ module Month
17
+ #
18
+ # Annotation 注釈
19
+ #
20
+ class Annotation
21
+ # @return [String] 注釈内容
22
+ attr_reader :description
23
+ # @return [String] 注釈補記
24
+ attr_reader :note
25
+
26
+ #
27
+ # 初期化
28
+ #
29
+ # @param [String] description 注釈内容
30
+ # @param [<Type>] note 注釈補記
31
+ #
32
+ def initialize(description:, note:)
33
+ @description = description
34
+ @note = note
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './history'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ #
8
+ # Result 演算結果
9
+ #
10
+ module Result
11
+ #
12
+ # 運用情報
13
+ #
14
+ module Operation
15
+ #
16
+ # Month 運用情報(月)
17
+ #
18
+ module Month
19
+ #
20
+ # Bundle 月履歴集約情報
21
+ #
22
+ class Bundle
23
+ # @return [History] 月別履歴情報(当月)
24
+ attr_reader :current
25
+ # @return [History] 月別履歴情報(影響を与えた月)
26
+ attr_reader :parent
27
+
28
+ def initialize(current: History.new, parent: History.new)
29
+ @current = current
30
+ @parent = parent
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './annotation'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ #
8
+ # Result 演算結果
9
+ #
10
+ module Result
11
+ #
12
+ # 運用情報
13
+ #
14
+ module Operation
15
+ #
16
+ # Month 運用情報(月)
17
+ #
18
+ module Month
19
+ #
20
+ # History 月別履歴情報
21
+ #
22
+ class History
23
+ # @return [String] ID
24
+ attr_reader :id
25
+ # @return [String] 月初日の西暦日
26
+ attr_reader :western_date
27
+ # @return [Integer] 原文頁数
28
+ attr_reader :page
29
+ # @return [Integer] 原文注釈番号
30
+ attr_reader :number
31
+ # @return [Array<Annotation>] 注釈
32
+ attr_reader :annotations
33
+
34
+ #
35
+ # 初期化
36
+ #
37
+ # @param [String] id ID
38
+ # @param [String] western_date 月初日の西暦日
39
+ # @param [Integer] page 原文頁数
40
+ # @param [Integer] number 原文注釈番号
41
+ # @param [Array<Annotation>] annotations 注釈
42
+ #
43
+ def initialize(id: '', western_date: '', page: -1, number: -1, annotations: [])
44
+ @id = id
45
+ @western_date = western_date
46
+ @page = page
47
+ @number = number
48
+ @annotations = annotations
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../data/single_day'
4
+
5
+ require_relative './month/bundle'
6
+
7
+ # :nodoc:
8
+ module Zakuro
9
+ #
10
+ # Result 演算結果
11
+ #
12
+ module Result
13
+ #
14
+ # 運用情報
15
+ #
16
+ module Operation
17
+ #
18
+ # Bundle 運用情報
19
+ #
20
+ class Bundle
21
+ # @return [True] 運用あり
22
+ # @return [False] 運用なし
23
+ attr_reader :operated
24
+ # @return [Month::Bundle] 月別履歴情報
25
+ attr_reader :month
26
+ # @return [Data::SingleDay] 計算値
27
+ attr_reader :original
28
+
29
+ #
30
+ # 初期化
31
+ #
32
+ # @param [True, False] operated 運用有無
33
+ # @param [Month::Bundle] month 月別履歴情報
34
+ # @param [Data::SingleDay] original 計算値
35
+ #
36
+ def initialize(operated:, month:, original:)
37
+ @operated = operated
38
+ @month = month
39
+ @original = original
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -2,9 +2,11 @@
2
2
 
3
3
  require 'json'
4
4
 
5
+ require_relative './data/single_day'
6
+
7
+ require_relative './operation/operation'
8
+
5
9
  require_relative './core'
6
- require_relative './data'
7
- require_relative './operation'
8
10
 
9
11
  # :nodoc:
10
12
  module Zakuro
@@ -33,5 +35,22 @@ module Zakuro
33
35
  @operation = operation
34
36
  end
35
37
  end
38
+
39
+ #
40
+ # Range 期間検索結果
41
+ #
42
+ class Range < Core
43
+ attr_reader :list
44
+
45
+ #
46
+ # 初期化
47
+ #
48
+ # @param [Array<Data::Single>] list 期間内データ
49
+ #
50
+ def initialize(list: [])
51
+ super
52
+ @list = list
53
+ end
54
+ end
36
55
  end
37
56
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../output/logger'
4
+
5
+ # :nodoc:
6
+ module Zakuro
7
+ #
8
+ # Tools 汎用メソッド群
9
+ #
10
+ module Tools
11
+ # :reek:UncommunicativeVariableName {accept: e}
12
+
13
+ #
14
+ # Typeconv 型変換
15
+ #
16
+ module Typeconv
17
+ LOGGER = Output::Logger.new(location: 'Typeconv')
18
+
19
+ #
20
+ # 文字列を10進数で数値化する
21
+ #
22
+ # @param [String] text 対象文字列
23
+ # @param [Integer] default デフォルト数値
24
+ #
25
+ # @return [Integer] 数値
26
+ #
27
+ def self.to_i(text:, default:)
28
+ begin
29
+ return Integer(text, 10)
30
+ rescue StandardError => e
31
+ LOGGER.debug(e)
32
+ end
33
+
34
+ default
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../calculation/cycle/abstract_remainder'
4
- require_relative '../era/western'
4
+ require_relative '../era/japan/calendar'
5
+ require_relative '../era/western/calendar'
5
6
 
6
7
  # :nodoc:
7
8
  module Zakuro
@@ -22,6 +23,8 @@ module Zakuro
22
23
  # @return [False] 時間型ではない
23
24
  #
24
25
  def self.time?(obj:)
26
+ return true if obj.is_a?(Japan::Calendar)
27
+
25
28
  return true if obj.is_a?(Western::Calendar)
26
29
 
27
30
  return true if obj.is_a?(Calculation::Cycle::AbstractRemainder)
@@ -8,16 +8,37 @@ module Zakuro
8
8
  # Context 暦コンテキスト
9
9
  #
10
10
  class Context
11
+ # @return [String] 暦名
11
12
  attr_reader :version_name
13
+ # @return [VersionClassResolver] 暦リゾルバー
12
14
  attr_reader :resolver
13
15
 
16
+ # @return [Array<String>] 暦名
14
17
  VERSION_NAMES = %w[Genka Gihou Daien Senmyou Joukyou Kansei Tenpou Gregorio].freeze
15
18
 
16
- def initialize(version_name:)
17
- raise ArgumentError.new, 'invalid version' unless VERSION_NAMES.include?(version_name)
18
-
19
+ #
20
+ # 初期化
21
+ #
22
+ # @param [String] version_name 暦名
23
+ #
24
+ def initialize(version_name: '')
19
25
  @version_name = version_name
26
+
27
+ if !invalid? && !VERSION_NAMES.include?(version_name)
28
+ raise ArgumentError.new, 'invalid version'
29
+ end
30
+
20
31
  @resolver = VersionClassResolver.new(version_name: version_name)
21
32
  end
33
+
34
+ #
35
+ # 不正か
36
+ #
37
+ # @return [True] 不正
38
+ # @return [False] 不正なし
39
+ #
40
+ def invalid?
41
+ @version_name.empty?
42
+ end
22
43
  end
23
44
  end
@@ -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
  # Daien 大衍暦
9
7
  #
10
8
  module Daien
11
- #
12
- # Gateway アクセサメソッド群
13
- #
14
- class Gateway < AbstractVersion
15
- # @return [True] リリースあり
16
- RELEASE = true
17
-
18
- # @return [String] 暦クラス名
19
- VERSION_NAME = 'Daien'
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