zakuro 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +3 -0
- data/README.md +6 -4
- data/VERSION +1 -1
- data/doc/operation/transfer.rb +8 -8
- data/lib/zakuro/calculation/base/gengou.rb +46 -0
- data/lib/zakuro/calculation/era/gengou/{scroll.rb → abstract_scroll.rb} +6 -8
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/{list.rb → abstract_list.rb} +37 -51
- data/lib/zakuro/calculation/era/gengou/internal/reserve/{range.rb → abstract_range.rb} +17 -17
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +158 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +75 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +2 -3
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
- data/lib/zakuro/calculation/monthly/month.rb +39 -0
- data/lib/zakuro/calculation/monthly/operated_month.rb +1 -1
- data/lib/zakuro/calculation/range/{full_range.rb → abstract_full_range.rb} +5 -4
- data/lib/zakuro/calculation/range/{operated_range.rb → abstract_operation_range.rb} +9 -11
- data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
- data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
- data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
- data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -2
- data/lib/zakuro/calculation/{specifier → summary}/internal/month.rb +1 -1
- data/lib/zakuro/calculation/summary/japan/range.rb +152 -0
- data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +91 -0
- data/lib/zakuro/calculation/summary/western/range.rb +124 -0
- data/lib/zakuro/calculation/summary/western/single.rb +113 -0
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +169 -0
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +93 -0
- data/lib/zakuro/condition.rb +1 -2
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +89 -74
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +125 -122
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +141 -122
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +171 -168
- data/lib/zakuro/era/japan/gengou/alignment.rb +38 -25
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +183 -182
- data/lib/zakuro/era/japan/gengou/resource/type.rb +233 -232
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +255 -254
- data/lib/zakuro/era/japan/gengou/resource.rb +23 -22
- data/lib/zakuro/era/japan/gengou.rb +5 -20
- data/lib/zakuro/era/western/calendar.rb +9 -9
- data/lib/zakuro/exception/case/pattern.rb +35 -0
- data/lib/zakuro/exception/case/preset.rb +51 -0
- data/lib/zakuro/exception/case/template.rb +48 -0
- data/lib/zakuro/exception/cause.rb +28 -0
- data/lib/zakuro/exception/exception.rb +37 -0
- data/lib/zakuro/exception/zakuro_error.rb +28 -0
- data/lib/zakuro/gateway/locale/date.rb +127 -0
- data/lib/zakuro/gateway/locale/range.rb +67 -0
- data/lib/zakuro/gateway/range.rb +99 -0
- data/lib/zakuro/gateway/single.rb +70 -0
- data/lib/zakuro/merchant.rb +8 -44
- data/lib/zakuro/operation/month/parser.rb +9 -9
- data/lib/zakuro/operation/month/type.rb +31 -31
- data/lib/zakuro/operation/month/validator.rb +49 -49
- data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
- data/lib/zakuro/output/logger.rb +17 -3
- data/lib/zakuro/result/data/day.rb +43 -0
- data/lib/zakuro/result/data/gengou.rb +35 -0
- data/lib/zakuro/result/data/month.rb +63 -0
- data/lib/zakuro/result/data/single_day.rb +48 -0
- data/lib/zakuro/result/data/solar_term.rb +35 -0
- data/lib/zakuro/result/data/year.rb +45 -0
- data/lib/zakuro/result/operation/month/annotation.rb +40 -0
- data/lib/zakuro/result/operation/month/bundle.rb +36 -0
- data/lib/zakuro/result/operation/month/history.rb +54 -0
- data/lib/zakuro/result/operation/operation.rb +44 -0
- data/lib/zakuro/result/result.rb +4 -2
- metadata +46 -14
- data/lib/zakuro/calculation/specifier/multiple_day.rb +0 -162
- data/lib/zakuro/calculation/specifier/single_day.rb +0 -87
- data/lib/zakuro/calculation/summary/range.rb +0 -120
- data/lib/zakuro/calculation/summary/single.rb +0 -110
- data/lib/zakuro/result/data.rb +0 -187
- data/lib/zakuro/result/operation.rb +0 -114
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './abstract_list'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Calculation
|
9
|
+
# :nodoc:
|
10
|
+
module Gengou
|
11
|
+
# :nodoc:
|
12
|
+
module Reserve
|
13
|
+
# NamedList
|
14
|
+
#
|
15
|
+
# 予約元号一覧(元号名)
|
16
|
+
#
|
17
|
+
class NamedList < AbstractList
|
18
|
+
# @return [String] 不正元号名
|
19
|
+
INVALID_NAME = Japan::Calendar::EMPTY
|
20
|
+
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
# @param [True, False] first true:1行目元号, false:2行目元号
|
25
|
+
# @param [String] start_name 開始元号名
|
26
|
+
# @param [String] last_name 終了元号名
|
27
|
+
#
|
28
|
+
def initialize(first: true, start_name: INVALID_NAME, last_name: INVALID_NAME)
|
29
|
+
@index = parse_index(first: first)
|
30
|
+
@start_date = Western::Calendar.new
|
31
|
+
@last_date = Western::Calendar.new
|
32
|
+
|
33
|
+
locate(start_name: start_name, last_name: last_name)
|
34
|
+
super(index: @index, start_date: @start_date, last_date: @last_date)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
#
|
40
|
+
# 開始日・終了日を配置する
|
41
|
+
#
|
42
|
+
# @param [String] start_name 開始元号名
|
43
|
+
# @param [String] last_name 終了元号名
|
44
|
+
#
|
45
|
+
def locate(start_name:, last_name:)
|
46
|
+
start = start_name
|
47
|
+
last = last_name
|
48
|
+
last = start if last == INVALID_NAME
|
49
|
+
|
50
|
+
return if start == INVALID_NAME
|
51
|
+
|
52
|
+
[start, last].each do |name|
|
53
|
+
gengou_list = line_by_name(name: name)
|
54
|
+
|
55
|
+
next if gengou_list.size.zero?
|
56
|
+
|
57
|
+
choise_start_date(
|
58
|
+
date: gengou_list[0].start_date.clone
|
59
|
+
)
|
60
|
+
choise_last_date(
|
61
|
+
date: gengou_list[-1].last_date.clone
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# 最古の開始日を選択する
|
68
|
+
#
|
69
|
+
# @param [Western::Calendar] date 西暦日
|
70
|
+
#
|
71
|
+
def choise_start_date(date:)
|
72
|
+
return if date.invalid?
|
73
|
+
|
74
|
+
if @start_date.invalid?
|
75
|
+
@start_date = date
|
76
|
+
return
|
77
|
+
end
|
78
|
+
|
79
|
+
return if date > @start_date
|
80
|
+
|
81
|
+
@start_date = date
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# 最新の終了日を選択する
|
86
|
+
#
|
87
|
+
# @param [Western::Calendar] date 西暦日
|
88
|
+
#
|
89
|
+
def choise_last_date(date:)
|
90
|
+
return if date.invalid?
|
91
|
+
|
92
|
+
if @last_date.invalid?
|
93
|
+
@last_date = date
|
94
|
+
return
|
95
|
+
end
|
96
|
+
|
97
|
+
return if date < @last_date
|
98
|
+
|
99
|
+
@last_date = date
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# 元号を取得する(元号名)
|
104
|
+
#
|
105
|
+
# @param [String] name 元号名
|
106
|
+
#
|
107
|
+
# @return [Array<Japan::Alignment::LinearGengou>] 元号
|
108
|
+
#
|
109
|
+
def line_by_name(name:)
|
110
|
+
Japan::Gengou.line_by_name(line: @index, name: name)
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# 予約元号一覧を更新する
|
115
|
+
#
|
116
|
+
# すでに解決済みの開始日・終了日をそのまま使用する(前後の元号を引き当てない)
|
117
|
+
#
|
118
|
+
def update
|
119
|
+
@list |= line(start_date: start_date, last_date: last_date)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './abstract_range'
|
4
|
+
require_relative './named_list'
|
5
|
+
|
6
|
+
# :nodoc:
|
7
|
+
module Zakuro
|
8
|
+
# :nodoc:
|
9
|
+
module Calculation
|
10
|
+
# :nodoc:
|
11
|
+
module Gengou
|
12
|
+
# :nodoc:
|
13
|
+
module Reserve
|
14
|
+
#
|
15
|
+
# NamedRange 予約済み計算範囲(元号名)
|
16
|
+
#
|
17
|
+
class NamedRange < AbstractRange
|
18
|
+
# @return [String] 不正元号名
|
19
|
+
INVALID_NAME = Japan::Calendar::EMPTY
|
20
|
+
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
# @param [String] start_name 開始元号名
|
25
|
+
# @param [String] last_name 終了元号名
|
26
|
+
#
|
27
|
+
def initialize(start_name: INVALID_NAME, last_name: INVALID_NAME)
|
28
|
+
@first_list = NamedList.new(first: true, start_name: start_name, last_name: last_name)
|
29
|
+
@second_list = NamedList.new(first: false, start_name: start_name, last_name: last_name)
|
30
|
+
|
31
|
+
start_date = western_start_date
|
32
|
+
last_date = western_last_date
|
33
|
+
|
34
|
+
super(start_date: start_date, last_date: last_date)
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# 最新の元号から西暦終了日を取得する
|
39
|
+
#
|
40
|
+
# @return [Western::Calendar] 西暦終了日
|
41
|
+
#
|
42
|
+
def western_last_date
|
43
|
+
list = newest_list
|
44
|
+
|
45
|
+
return Western::Calendar.new if list.invalid?
|
46
|
+
|
47
|
+
list.western_last_date
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# 最新の元号を取得する
|
52
|
+
#
|
53
|
+
# @return [List] 最新の元号
|
54
|
+
#
|
55
|
+
def newest_list
|
56
|
+
return @first_list if @first_list.invalid?
|
57
|
+
|
58
|
+
return @first_list if @second_list.invalid?
|
59
|
+
|
60
|
+
first_western_date = @first_list.western_last_date
|
61
|
+
second_western_date = @second_list.western_last_date
|
62
|
+
|
63
|
+
return @first_list if first_western_date.invalid?
|
64
|
+
|
65
|
+
return @first_list if second_western_date.invalid?
|
66
|
+
|
67
|
+
return @first_list if first_western_date > second_western_date
|
68
|
+
|
69
|
+
@second_list
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../../../../era/western/calendar'
|
4
|
-
require_relative './reserve/
|
5
|
-
require_relative './reserve/list'
|
4
|
+
require_relative './reserve/dated_range'
|
6
5
|
|
7
6
|
# :nodoc:
|
8
7
|
module Zakuro
|
@@ -34,7 +33,7 @@ module Zakuro
|
|
34
33
|
# @return [Range] 予約済み計算範囲
|
35
34
|
#
|
36
35
|
def self.get(start_date: Western::Calendar.new, last_date: Western::Calendar.new)
|
37
|
-
|
36
|
+
DatedRange.new(start_date: start_date, last_date: last_date)
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './abstract_scroll'
|
4
|
+
require_relative './internal/reserve/named_range'
|
5
|
+
|
6
|
+
# :nodoc:
|
7
|
+
module Zakuro
|
8
|
+
# :nodoc:
|
9
|
+
module Calculation
|
10
|
+
# :nodoc:
|
11
|
+
module Gengou
|
12
|
+
# NamedScroll
|
13
|
+
#
|
14
|
+
# 元号スクロール
|
15
|
+
#
|
16
|
+
class NamedScroll < AbstractScroll
|
17
|
+
#
|
18
|
+
# 初期化
|
19
|
+
#
|
20
|
+
# @param [String] start_name 開始元号名
|
21
|
+
# @param [String] last_name 終了元号名
|
22
|
+
#
|
23
|
+
def initialize(start_name: INVALID_NAME, last_name: INVALID_NAME)
|
24
|
+
range = Reserve::NamedRange.new(start_name: start_name, last_name: last_name)
|
25
|
+
super(range: range)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -228,6 +228,45 @@ module Zakuro
|
|
228
228
|
|
229
229
|
true
|
230
230
|
end
|
231
|
+
|
232
|
+
#
|
233
|
+
# 範囲内か
|
234
|
+
#
|
235
|
+
# @param [Japan::Calendar] date 日付
|
236
|
+
#
|
237
|
+
# @return [True] 範囲内
|
238
|
+
# @return [False] 範囲外
|
239
|
+
#
|
240
|
+
def include_by_japan_date?(date:)
|
241
|
+
return false if invalid?
|
242
|
+
|
243
|
+
linear_gengou = @gengou.match_by_name(name: date.gengou)
|
244
|
+
return false if linear_gengou.invalid?
|
245
|
+
|
246
|
+
return false unless linear_gengou.name == date.gengou
|
247
|
+
|
248
|
+
return false unless linear_gengou.year == date.year
|
249
|
+
|
250
|
+
same_by_japan_date?(date: date)
|
251
|
+
end
|
252
|
+
|
253
|
+
private
|
254
|
+
|
255
|
+
#
|
256
|
+
# 同一の月情報かを検証する
|
257
|
+
#
|
258
|
+
# @param [Japan::Calendar] date 日付
|
259
|
+
#
|
260
|
+
# @return [True] 同一の月
|
261
|
+
# @return [False] 異なる月
|
262
|
+
#
|
263
|
+
def same_by_japan_date?(date: Japan::Calendar.new)
|
264
|
+
return false unless number == date.month
|
265
|
+
|
266
|
+
return false unless leaped? == date.leaped
|
267
|
+
|
268
|
+
true
|
269
|
+
end
|
231
270
|
end
|
232
271
|
end
|
233
272
|
end
|
@@ -5,7 +5,6 @@ require_relative '../../version/context'
|
|
5
5
|
require_relative '../../era/western/calendar'
|
6
6
|
require_relative '../../output/logger'
|
7
7
|
|
8
|
-
require_relative '../era/gengou/scroll'
|
9
8
|
require_relative '../era/version/version'
|
10
9
|
|
11
10
|
require_relative '../base/gengou'
|
@@ -35,7 +34,7 @@ module Zakuro
|
|
35
34
|
# * 引き当てたい日付が元旦ではない場合、その月日に従い元号を再度求める
|
36
35
|
# * この再計算が必要になるのは、元号が切り替わる年のみである
|
37
36
|
#
|
38
|
-
class
|
37
|
+
class AbstractFullRange
|
39
38
|
# @return [Context] 暦コンテキスト
|
40
39
|
attr_reader :context
|
41
40
|
# @return [Western::Calendar] 開始日
|
@@ -52,17 +51,19 @@ module Zakuro
|
|
52
51
|
# 初期化
|
53
52
|
#
|
54
53
|
# @param [Context] context 暦コンテキスト
|
54
|
+
# @param [Gengou::AbstractScroll] scroll 元号スクロール
|
55
55
|
# @param [Western::Calendar] start_date 開始日
|
56
56
|
# @param [Western::Calendar] last_date 終了日
|
57
57
|
#
|
58
|
-
def initialize(context:,
|
58
|
+
def initialize(context:, scroll:,
|
59
|
+
start_date: Western::Calendar.new, last_date: Western::Calendar.new)
|
59
60
|
@start_date = start_date
|
60
61
|
@last_date = last_date
|
61
62
|
return if invalid?
|
62
63
|
|
63
64
|
# TODO: 現時点では使用していない。特定の暦を指定できるようになった状態で使用する
|
64
65
|
@context = context
|
65
|
-
@scroll =
|
66
|
+
@scroll = scroll
|
66
67
|
end
|
67
68
|
|
68
69
|
#
|
@@ -13,10 +13,10 @@ module Zakuro
|
|
13
13
|
# :nodoc:
|
14
14
|
module Range
|
15
15
|
#
|
16
|
-
#
|
16
|
+
# AbstractOperationRange 運用結果範囲
|
17
17
|
#
|
18
18
|
# 何らかの理由により、計算された暦とは異なる運用結果である場合、その結果に合わせて計算結果を上書きする
|
19
|
-
class
|
19
|
+
class AbstractOperationRange
|
20
20
|
# @return [Array<Year>] 年データ(完全範囲)
|
21
21
|
attr_reader :years
|
22
22
|
# @return [OperatedSolarTerms] 運用時二十四節気
|
@@ -28,15 +28,13 @@ module Zakuro
|
|
28
28
|
# 初期化
|
29
29
|
#
|
30
30
|
# @param [Context] context 暦コンテキスト
|
31
|
-
# @param [
|
32
|
-
# @param [Western::Calendar] last_date 終了日
|
31
|
+
# @param [Gengou::AbstractScroll] scroll 元号スクロール
|
33
32
|
# @param [Array<Year>] years 年データ(完全範囲)
|
34
33
|
#
|
35
|
-
def initialize(context:,
|
36
|
-
years: [])
|
34
|
+
def initialize(context:, scroll:, years: [])
|
37
35
|
@context = context
|
38
36
|
@years = years
|
39
|
-
@scroll =
|
37
|
+
@scroll = scroll
|
40
38
|
@operated_solar_terms = OperatedSolarTerms.new(context: context, years: @years)
|
41
39
|
@operated_solar_terms.create
|
42
40
|
end
|
@@ -49,9 +47,9 @@ module Zakuro
|
|
49
47
|
def get
|
50
48
|
operated_years = rewrite
|
51
49
|
|
52
|
-
|
50
|
+
AbstractOperationRange.move(operated_years: operated_years)
|
53
51
|
|
54
|
-
|
52
|
+
AbstractOperationRange.commit(operated_years: operated_years)
|
55
53
|
|
56
54
|
Transfer::GengouScroller.set(scroll: @scroll, years: operated_years)
|
57
55
|
|
@@ -67,7 +65,7 @@ module Zakuro
|
|
67
65
|
operated_years = []
|
68
66
|
|
69
67
|
years.each do |year|
|
70
|
-
operated_year =
|
68
|
+
operated_year = AbstractOperationRange.rewrite_year(
|
71
69
|
year: year,
|
72
70
|
operated_solar_terms: @operated_solar_terms
|
73
71
|
)
|
@@ -157,7 +155,7 @@ module Zakuro
|
|
157
155
|
def self.resolve_month(context:, month:, operated_solar_terms:)
|
158
156
|
history = Operation.specify_history(western_date: month.western_date)
|
159
157
|
|
160
|
-
|
158
|
+
AbstractOperationRange.rewrite_month(
|
161
159
|
context: context, month: month, history: history,
|
162
160
|
operated_solar_terms: operated_solar_terms
|
163
161
|
)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../era/gengou/dated_scroll'
|
4
|
+
require_relative './abstract_full_range'
|
5
|
+
|
6
|
+
# :nodoc:
|
7
|
+
module Zakuro
|
8
|
+
# :nodoc:
|
9
|
+
module Calculation
|
10
|
+
# :nodoc:
|
11
|
+
module Range
|
12
|
+
#
|
13
|
+
# DatedFullRange 完全範囲
|
14
|
+
#
|
15
|
+
class DatedFullRange < AbstractFullRange
|
16
|
+
#
|
17
|
+
# 初期化
|
18
|
+
#
|
19
|
+
# @param [Context] context 暦コンテキスト
|
20
|
+
# @param [Western::Calendar] start_date 開始日
|
21
|
+
# @param [Western::Calendar] last_date 終了日
|
22
|
+
#
|
23
|
+
def initialize(context:,
|
24
|
+
start_date: Western::Calendar.new, last_date: Western::Calendar.new)
|
25
|
+
scroll = Gengou::DatedScroll.new(start_date: start_date, last_date: last_date)
|
26
|
+
|
27
|
+
super(context: context, scroll: scroll, start_date: start_date, last_date: last_date)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../era/gengou/dated_scroll'
|
4
|
+
|
5
|
+
require_relative './abstract_operation_range'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Calculation
|
11
|
+
# :nodoc:
|
12
|
+
module Range
|
13
|
+
#
|
14
|
+
# DatedOperationRange 運用結果範囲
|
15
|
+
#
|
16
|
+
class DatedOperationRange < AbstractOperationRange
|
17
|
+
#
|
18
|
+
# 初期化
|
19
|
+
#
|
20
|
+
# @param [Context] context 暦コンテキスト
|
21
|
+
# @param [Western::Calendar] start_date 開始日
|
22
|
+
# @param [Western::Calendar] last_date 終了日
|
23
|
+
# @param [Array<Year>] years 年データ(完全範囲)
|
24
|
+
#
|
25
|
+
def initialize(context:, start_date: Western::Calendar.new,
|
26
|
+
last_date: Western::Calendar.new, years: [])
|
27
|
+
scroll = Gengou::DatedScroll.new(start_date: start_date, last_date: last_date)
|
28
|
+
super(context: context, scroll: scroll, years: years)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../era/gengou/named_scroll'
|
4
|
+
require_relative './abstract_full_range'
|
5
|
+
|
6
|
+
# :nodoc:
|
7
|
+
module Zakuro
|
8
|
+
# :nodoc:
|
9
|
+
module Calculation
|
10
|
+
# :nodoc:
|
11
|
+
module Range
|
12
|
+
#
|
13
|
+
# NamedFullRange 完全範囲
|
14
|
+
#
|
15
|
+
class NamedFullRange < AbstractFullRange
|
16
|
+
# @return [String] 不正元号名
|
17
|
+
INVALID_NAME = Japan::Calendar::EMPTY
|
18
|
+
|
19
|
+
#
|
20
|
+
# 初期化
|
21
|
+
#
|
22
|
+
# @param [Context] context 暦コンテキスト
|
23
|
+
# @param [String] start_name 開始元号名
|
24
|
+
# @param [String] last_name 終了元号名
|
25
|
+
#
|
26
|
+
def initialize(context:, start_name: INVALID_NAME, last_name: INVALID_NAME)
|
27
|
+
scroll = Gengou::NamedScroll.new(start_name: start_name, last_name: last_name)
|
28
|
+
range = scroll.range
|
29
|
+
|
30
|
+
super(
|
31
|
+
context: context, scroll: scroll,
|
32
|
+
start_date: range.western_start_date, last_date: range.western_last_date
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../era/gengou/named_scroll'
|
4
|
+
|
5
|
+
require_relative './abstract_operation_range'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Calculation
|
11
|
+
# :nodoc:
|
12
|
+
module Range
|
13
|
+
#
|
14
|
+
# NamedOperationRange 運用結果範囲
|
15
|
+
#
|
16
|
+
class NamedOperationRange < AbstractOperationRange
|
17
|
+
# @return [String] 不正元号名
|
18
|
+
INVALID_NAME = Japan::Calendar::EMPTY
|
19
|
+
|
20
|
+
#
|
21
|
+
# 初期化
|
22
|
+
#
|
23
|
+
# @param [Context] context 暦コンテキスト
|
24
|
+
# @param [String] start_name 開始元号名
|
25
|
+
# @param [String] last_name 終了元号名
|
26
|
+
# @param [Array<Year>] years 年データ(完全範囲)
|
27
|
+
#
|
28
|
+
def initialize(context:, start_name: INVALID_NAME, last_name: INVALID_NAME, years: [])
|
29
|
+
scroll = Gengou::NamedScroll.new(start_name: start_name, last_name: last_name)
|
30
|
+
|
31
|
+
super(context: context, scroll: scroll, years: years)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|