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
@@ -72,15 +72,7 @@ module Zakuro
72
72
  def ignite(month:)
73
73
  return false unless ignitable?(month: month)
74
74
 
75
- japan_start_date = @range.japan_start_date
76
-
77
- western_start_date = @range.western_start_date
78
-
79
- # 今月初日(和暦日が1月2日であれば、開始日の1日前が初日)
80
- @monthly_start_date = western_start_date.clone - japan_start_date.day + 1
81
-
82
- # 今月末
83
- @monthly_last_date = @monthly_start_date.clone + month.days - 1
75
+ first_monthly_date(month: month)
84
76
 
85
77
  update_current_gengou
86
78
 
@@ -93,9 +85,9 @@ module Zakuro
93
85
  # @param [Monthly::Month] month 月
94
86
  #
95
87
  def advance(month:)
96
- @monthly_start_date = @monthly_last_date.clone + 1
88
+ @monthly_start_date = monthly_last_date.clone + 1
97
89
 
98
- @monthly_last_date = @monthly_start_date.clone + month.days - 1
90
+ @monthly_last_date = monthly_start_date.clone + month.days - 1
99
91
 
100
92
  next_year if month.number == 1 && !month.leaped?
101
93
 
@@ -108,15 +100,15 @@ module Zakuro
108
100
  # @return [Base::Gengou] 元号
109
101
  #
110
102
  def to_gengou
111
- start_date = @monthly_start_date.clone
112
- last_date = @monthly_last_date.clone
103
+ start_date = monthly_start_date.clone
104
+ last_date = monthly_last_date.clone
113
105
 
114
106
  # 行を超えた元号切り替え処理
115
107
  continue_year
116
108
 
117
109
  Publisher.run(
118
110
  start_date: start_date, last_date: last_date,
119
- first_gengou: @first_gengou, second_gengou: @second_gengou
111
+ first_gengou: first_gengou, second_gengou: second_gengou
120
112
  )
121
113
  end
122
114
 
@@ -126,7 +118,7 @@ module Zakuro
126
118
  # @return [Integer] 開始西暦年
127
119
  #
128
120
  def western_start_year
129
- @range.western_start_year
121
+ range.western_start_year
130
122
  end
131
123
 
132
124
  #
@@ -135,30 +127,47 @@ module Zakuro
135
127
  # @return [Integer] 終了西暦年
136
128
  #
137
129
  def western_last_year
138
- @range.western_last_year
130
+ range.western_last_year
139
131
  end
140
132
 
141
133
  private
142
134
 
135
+ #
136
+ # 最初の月初日/末日を設定する
137
+ #
138
+ # @param [Monthly::Month] month 月
139
+ #
140
+ def first_monthly_date(month:)
141
+ japan_start_date = range.japan_start_date
142
+
143
+ western_start_date = range.western_start_date
144
+
145
+ # 今月初日(和暦日が1月2日であれば、開始日の1日前が初日)
146
+ @monthly_start_date = western_start_date.clone - japan_start_date.day + 1
147
+
148
+ # 今月末
149
+ @monthly_last_date = monthly_start_date.clone + month.days - 1
150
+ end
151
+
143
152
  #
144
153
  # 行を跨ぐ元号年を継続させる
145
154
  #
146
155
  def continue_year
147
- @connector.update(lines: [@first_gengou, @second_gengou])
156
+ connector.update(lines: [first_gengou, second_gengou])
148
157
  end
149
158
 
150
159
  #
151
160
  # 現在月に合わせて元号を更新する
152
161
  #
153
162
  def update_current_gengou
154
- start_date = @monthly_start_date
155
- last_date = @monthly_last_date
156
- first_gengou = @range.collect_first(start_date: start_date, last_date: last_date)
157
- second_gengou = @range.collect_second(start_date: start_date,
158
- last_date: last_date)
159
-
160
- @first_gengou = replace_gengou(source: @first_gengou, destination: first_gengou)
161
- @second_gengou = replace_gengou(source: @second_gengou, destination: second_gengou)
163
+ start_date = monthly_start_date
164
+ last_date = monthly_last_date
165
+ dest_first_gengou = range.collect_first(start_date: start_date, last_date: last_date)
166
+ dest_second_gengou = range.collect_second(start_date: start_date,
167
+ last_date: last_date)
168
+
169
+ @first_gengou = replace_gengou(source: first_gengou, destination: dest_first_gengou)
170
+ @second_gengou = replace_gengou(source: second_gengou, destination: dest_second_gengou)
162
171
  end
163
172
 
164
173
  #
@@ -189,9 +198,9 @@ module Zakuro
189
198
  # @return [True] 開始不可
190
199
  #
191
200
  def ignitable?(month:)
192
- return false unless @monthly_start_date.invalid?
201
+ return false unless monthly_start_date.invalid?
193
202
 
194
- japan_start_date = @range.japan_start_date
203
+ japan_start_date = range.japan_start_date
195
204
 
196
205
  japan_start_date.same_month?(leaped: month.leaped?, month: month.number)
197
206
  end
@@ -200,8 +209,8 @@ module Zakuro
200
209
  # 次年にする
201
210
  #
202
211
  def next_year
203
- @first_gengou.each(&:next_year)
204
- @second_gengou.each(&:next_year)
212
+ first_gengou.each(&:next_year)
213
+ second_gengou.each(&:next_year)
205
214
  end
206
215
  end
207
216
  end
@@ -60,7 +60,7 @@ module Zakuro
60
60
  #
61
61
  def replace(gengou:)
62
62
  matched_index = -1
63
- @unsolved_list.each_with_index do |unsolved, index|
63
+ unsolved_list.each_with_index do |unsolved, index|
64
64
  next unless unsolved.name == gengou.name
65
65
 
66
66
  matched_index = index
@@ -68,18 +68,18 @@ module Zakuro
68
68
  end
69
69
 
70
70
  if matched_index == -1
71
- @unsolved_list.push(gengou)
71
+ unsolved_list.push(gengou)
72
72
  return gengou
73
73
  end
74
74
 
75
- matched = @unsolved_list[matched_index]
75
+ matched = unsolved_list[matched_index]
76
76
 
77
77
  result = recreate(gengou: gengou, unsolved: matched)
78
78
 
79
79
  @unsolved_list[matched_index] = result
80
80
 
81
81
  # 分離した元号の末尾まで到達した
82
- @unsolved_list.delete_at(matched_index) unless result.change_last_date?
82
+ unsolved_list.delete_at(matched_index) unless result.change_last_date?
83
83
 
84
84
  result
85
85
  end
@@ -56,9 +56,9 @@ module Zakuro
56
56
  # @return [Japan::Calendar] 和暦開始日
57
57
  #
58
58
  def japan_start_date
59
- return Japan::Calendar.new if @gengou.invalid?
59
+ return Japan::Calendar.new if gengou.invalid?
60
60
 
61
- @gengou.both_start_date.japan
61
+ gengou.both_start_date.japan
62
62
  end
63
63
 
64
64
  #
@@ -67,9 +67,9 @@ module Zakuro
67
67
  # @return [Western::Calendar] 西暦開始日
68
68
  #
69
69
  def western_start_date
70
- return Western::Calendar.new if @gengou.invalid?
70
+ return Western::Calendar.new if gengou.invalid?
71
71
 
72
- @start_date
72
+ start_date
73
73
  end
74
74
 
75
75
  #
@@ -78,9 +78,9 @@ module Zakuro
78
78
  # @return [Western::Calendar] 西暦終了日
79
79
  #
80
80
  def western_last_date
81
- return Western::Calendar.new if @gengou.invalid?
81
+ return Western::Calendar.new if gengou.invalid?
82
82
 
83
- @last_date
83
+ last_date
84
84
  end
85
85
 
86
86
  #
@@ -103,7 +103,7 @@ module Zakuro
103
103
  def name
104
104
  return '' unless @gengou
105
105
 
106
- @gengou.name
106
+ gengou.name
107
107
  end
108
108
 
109
109
  #
@@ -113,7 +113,7 @@ module Zakuro
113
113
  # @return [False] 不正なし
114
114
  #
115
115
  def invalid?
116
- @gengou.invalid? || @japan_year == INVALID_YEAR || @western_year == INVALID_YEAR
116
+ gengou.invalid? || japan_year == INVALID_YEAR || western_year == INVALID_YEAR
117
117
  end
118
118
 
119
119
  #
@@ -125,7 +125,7 @@ module Zakuro
125
125
  # @return [False] 含まれない
126
126
  #
127
127
  def include?
128
- @gengou.include?
128
+ gengou.include?
129
129
  end
130
130
 
131
131
  #
@@ -151,7 +151,7 @@ module Zakuro
151
151
  def change_start_date?
152
152
  return false if invalid?
153
153
 
154
- @start_date != native_start_date
154
+ start_date != native_start_date
155
155
  end
156
156
 
157
157
  #
@@ -163,7 +163,7 @@ module Zakuro
163
163
  def change_last_date?
164
164
  return false if invalid?
165
165
 
166
- @last_date != native_last_date
166
+ last_date != native_last_date
167
167
  end
168
168
 
169
169
  #
@@ -185,10 +185,10 @@ module Zakuro
185
185
  # 有効な日付範囲を選択する
186
186
  #
187
187
  def select_valid_date
188
- return if @gengou.invalid?
188
+ return if gengou.invalid?
189
189
 
190
- @start_date = @gengou.both_start_date.western.clone if @start_date.invalid?
191
- @last_date = @gengou.last_date.clone if @last_date.invalid?
190
+ @start_date = gengou.both_start_date.western.clone if start_date.invalid?
191
+ @last_date = gengou.last_date.clone if last_date.invalid?
192
192
  end
193
193
 
194
194
  #
@@ -197,7 +197,7 @@ module Zakuro
197
197
  # @return [Western::Calendar]設定された元号の開始日
198
198
  #
199
199
  def native_start_date
200
- @gengou.both_start_date.western
200
+ gengou.both_start_date.western
201
201
  end
202
202
 
203
203
  #
@@ -206,7 +206,7 @@ module Zakuro
206
206
  # @return [Western::Calendar] 設定された元号の終了日
207
207
  #
208
208
  def native_last_date
209
- @gengou.last_date
209
+ gengou.last_date
210
210
  end
211
211
  end
212
212
  end
@@ -14,89 +14,91 @@ module Zakuro
14
14
  # 元号発行
15
15
  #
16
16
  module Publisher
17
- #
18
- # 発行する
19
- #
20
- # @param [Western::Calendar] start_date 西暦開始日
21
- # @param [Western::Calendar] last_date 西暦終了日
22
- # @param [Array<Counter>] first_gengou 1行目元号
23
- # @param [Array<Counter>] second_gengou 2行目元号
24
- #
25
- # @return [Base::Gengou] 元号
26
- #
27
- def self.run(start_date: Western::Calendar.new, last_date: Western::Calendar.new,
28
- first_gengou: [], second_gengou: [])
17
+ class << self
18
+ #
19
+ # 発行する
20
+ #
21
+ # @param [Western::Calendar] start_date 西暦開始日
22
+ # @param [Western::Calendar] last_date 西暦終了日
23
+ # @param [Array<Counter>] first_gengou 1行目元号
24
+ # @param [Array<Counter>] second_gengou 2行目元号
25
+ #
26
+ # @return [Base::Gengou] 元号
27
+ #
28
+ def run(start_date: Western::Calendar.new, last_date: Western::Calendar.new,
29
+ first_gengou: [], second_gengou: [])
29
30
 
30
- Base::Gengou.new(
31
- start_date: start_date,
32
- last_date: last_date,
33
- first_line: to_linear_gengou(
34
- start_date: start_date, last_date: last_date, gengou_list: first_gengou
35
- ),
36
- second_line: to_linear_gengou(
37
- start_date: start_date, last_date: last_date, gengou_list: second_gengou
31
+ Base::Gengou.new(
32
+ start_date: start_date,
33
+ last_date: last_date,
34
+ first_line: to_linear_gengou(
35
+ start_date: start_date, last_date: last_date, gengou_list: first_gengou
36
+ ),
37
+ second_line: to_linear_gengou(
38
+ start_date: start_date, last_date: last_date, gengou_list: second_gengou
39
+ )
38
40
  )
39
- )
40
- end
41
+ end
42
+
43
+ #
44
+ # 直列元号に変換する
45
+ #
46
+ # * 最初の元号:開始日~その元号の終了日
47
+ # * 中間の元号:その元号の開始日~その元号の終了日
48
+ # * 最後の元号:その元号の開始日~終了日
49
+ #
50
+ # @param [Western::Calendar] start_date 西暦開始日
51
+ # @param [Western::Calendar] last_date 西暦終了日
52
+ # @param [Array<Counter>] gengou_list 元号リスト
53
+ #
54
+ # @return [Array<Base::LinearGengou>] 元号リスト
55
+ #
56
+ def to_linear_gengou(start_date:, last_date:, gengou_list: [])
57
+ return [] if gengou_list.size.zero?
41
58
 
42
- #
43
- # 直列元号に変換する
44
- #
45
- # * 最初の元号:開始日~その元号の終了日
46
- # * 中間の元号:その元号の開始日~その元号の終了日
47
- # * 最後の元号:その元号の開始日~終了日
48
- #
49
- # @param [Western::Calendar] start_date 西暦開始日
50
- # @param [Western::Calendar] last_date 西暦終了日
51
- # @param [Array<Counter>] gengou_list 元号リスト
52
- #
53
- # @return [Array<Base::LinearGengou>] 元号リスト
54
- #
55
- def self.to_linear_gengou(start_date:, last_date:, gengou_list: [])
56
- return [] if gengou_list.size.zero?
59
+ result = []
57
60
 
58
- result = []
61
+ gengou_list.each do |gengou|
62
+ if gengou.invalid?
63
+ # 無効元号は無効のままにする
64
+ result.push(Base::LinearGengou.new)
65
+ next
66
+ end
59
67
 
60
- gengou_list.each do |gengou|
61
- if gengou.invalid?
62
- # 無効元号は無効のままにする
63
- result.push(Base::LinearGengou.new)
64
- next
68
+ linear_gengou = to_limited_linear_gengou(
69
+ start_date: start_date,
70
+ last_date: last_date,
71
+ gengou: gengou
72
+ )
73
+ result.push(linear_gengou)
65
74
  end
66
75
 
67
- linear_gengou = to_limited_linear_gengou(
68
- start_date: start_date,
69
- last_date: last_date,
70
- gengou: gengou
71
- )
72
- result.push(linear_gengou)
76
+ result
73
77
  end
74
78
 
75
- result
76
- end
77
-
78
- #
79
- # 範囲を限定した直列元号に変換する
80
- #
81
- # * 開始日・終了日により範囲を狭める
82
- #
83
- # @param [Western::Calendar] start_date 西暦開始日
84
- # @param [Western::Calendar] last_date 西暦終了日
85
- # @param [Counter] gengou 加算元号
86
- #
87
- # @return [Base::LinearGengou] 元号
88
- #
89
- def self.to_limited_linear_gengou(start_date:, last_date:, gengou:)
90
- gengou_start_date = gengou.western_start_date.clone
91
- gengou_last_date = gengou.western_last_date.clone
79
+ #
80
+ # 範囲を限定した直列元号に変換する
81
+ #
82
+ # * 開始日・終了日により範囲を狭める
83
+ #
84
+ # @param [Western::Calendar] start_date 西暦開始日
85
+ # @param [Western::Calendar] last_date 西暦終了日
86
+ # @param [Counter] gengou 加算元号
87
+ #
88
+ # @return [Base::LinearGengou] 元号
89
+ #
90
+ def to_limited_linear_gengou(start_date:, last_date:, gengou:)
91
+ gengou_start_date = gengou.western_start_date.clone
92
+ gengou_last_date = gengou.western_last_date.clone
92
93
 
93
- gengou_start_date = start_date.clone if start_date > gengou_start_date
94
- gengou_last_date = last_date.clone if last_date < gengou_last_date
94
+ gengou_start_date = start_date.clone if start_date > gengou_start_date
95
+ gengou_last_date = last_date.clone if last_date < gengou_last_date
95
96
 
96
- Base::LinearGengou.new(
97
- start_date: gengou_start_date, last_date: gengou_last_date,
98
- name: gengou.name, year: gengou.japan_year
99
- )
97
+ Base::LinearGengou.new(
98
+ start_date: gengou_start_date, last_date: gengou_last_date,
99
+ name: gengou.name, year: gengou.japan_year
100
+ )
101
+ end
100
102
  end
101
103
  end
102
104
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  require_relative '../../../../../era/japan/gengou/resource'
4
4
  require_relative '../../../../../era/japan/gengou'
@@ -61,7 +61,7 @@ module Zakuro
61
61
  # @return [Gengou::Counter] 加算元号
62
62
  #
63
63
  def get(western_date: Western::Calendar.new)
64
- @list.each do |linear_gengou|
64
+ list.each do |linear_gengou|
65
65
  next if linear_gengou.out?(start_date: western_date, last_date: western_date)
66
66
 
67
67
  Gengou::Counter.new(gengou: linear_gengou.gengou).clone
@@ -81,7 +81,7 @@ module Zakuro
81
81
  def collect(start_date: Western::Calendar.new, last_date: Western::Calendar.new)
82
82
  result = []
83
83
 
84
- @list.each do |linear_gengou|
84
+ list.each do |linear_gengou|
85
85
  next if linear_gengou.out?(start_date: start_date, last_date: last_date)
86
86
 
87
87
  result.push(
@@ -106,7 +106,7 @@ module Zakuro
106
106
  def japan_start_date
107
107
  return Japan::Calendar.new if invalid?
108
108
 
109
- @list[0].gengou.both_start_date.japan.clone
109
+ list[0].gengou.both_start_date.japan.clone
110
110
  end
111
111
 
112
112
  #
@@ -117,7 +117,7 @@ module Zakuro
117
117
  def western_start_date
118
118
  return Western::Calendar.new if invalid?
119
119
 
120
- @list[0].gengou.both_start_date.western.clone
120
+ list[0].gengou.both_start_date.western.clone
121
121
  end
122
122
 
123
123
  #
@@ -128,7 +128,7 @@ module Zakuro
128
128
  def western_last_date
129
129
  return Western::Calendar.new if invalid?
130
130
 
131
- @list[-1].gengou.last_date.clone
131
+ list[-1].gengou.last_date.clone
132
132
  end
133
133
 
134
134
  #
@@ -139,7 +139,7 @@ module Zakuro
139
139
  def western_start_year
140
140
  return INVALID_YEAR if invalid?
141
141
 
142
- @list[0].gengou.both_start_year.western.clone
142
+ list[0].gengou.both_start_year.western.clone
143
143
  end
144
144
 
145
145
  #
@@ -150,9 +150,9 @@ module Zakuro
150
150
  def western_last_year
151
151
  return INVALID_YEAR if invalid?
152
152
 
153
- return INVALID_YEAR if @list.size.zero?
153
+ return INVALID_YEAR if list.size.zero?
154
154
 
155
- @list[-1].gengou.last_year
155
+ list[-1].gengou.last_year
156
156
  end
157
157
 
158
158
  #
@@ -162,9 +162,9 @@ module Zakuro
162
162
  # @return [False] 不正なし
163
163
  #
164
164
  def invalid?
165
- return true unless @list
165
+ return true unless list
166
166
 
167
- return true if @list.size.zero?
167
+ return true if list.size.zero?
168
168
 
169
169
  false
170
170
  end
@@ -175,9 +175,9 @@ module Zakuro
175
175
  # @return [Western::Calendar]設定された元号の開始日
176
176
  #
177
177
  def native_start_date
178
- return Western::Calendar.new if @list.size.zero?
178
+ return Western::Calendar.new if list.size.zero?
179
179
 
180
- @list[0].native_start_date
180
+ list[0].native_start_date
181
181
  end
182
182
 
183
183
  #
@@ -187,9 +187,9 @@ module Zakuro
187
187
  # @return [False] 同一
188
188
  #
189
189
  def change_start_date?
190
- return false if @list.size.zero?
190
+ return false if list.size.zero?
191
191
 
192
- @list[0].change_start_date?
192
+ list[0].change_start_date?
193
193
  end
194
194
 
195
195
  private
@@ -210,7 +210,7 @@ module Zakuro
210
210
  # @return [Array<Japan::Alignment::LinearGengou>] 元号
211
211
  #
212
212
  def line(start_date:, last_date:)
213
- Japan::Gengou.line(line: @index, start_date: start_date, last_date: last_date)
213
+ Japan::Gengou.line(line: index, start_date: start_date, last_date: last_date)
214
214
  end
215
215
 
216
216
  #