zakuro 0.9.1 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -18
- data/VERSION +1 -1
- data/doc/condition.md +3 -1
- data/doc/dropped_date.md +25 -0
- data/doc/expection.md +11 -0
- data/doc/operation/csv/month.csv +5 -5
- data/doc/operation/operation.xlsx +0 -0
- data/doc/vanished_date.md +26 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +26 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +1 -1
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +2 -2
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +6 -2
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +5 -5
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +12 -5
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +14 -8
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +4 -2
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +5 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +10 -5
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +5 -2
- data/lib/zakuro/calculation/monthly/initialized_month.rb +4 -2
- data/lib/zakuro/calculation/monthly/meta/all_solar_term.rb +64 -0
- data/lib/zakuro/calculation/monthly/meta/meta_collector.rb +80 -0
- data/lib/zakuro/calculation/monthly/meta.rb +60 -0
- data/lib/zakuro/calculation/monthly/month.rb +60 -5
- data/lib/zakuro/calculation/monthly/operated_month.rb +6 -3
- data/lib/zakuro/calculation/option/dropped_date/location.rb +12 -23
- data/lib/zakuro/calculation/option/vanished_date/location.rb +9 -2
- data/lib/zakuro/calculation/range/abstract_full_range.rb +19 -2
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +20 -2
- data/lib/zakuro/calculation/range/dated_full_range.rb +3 -1
- data/lib/zakuro/calculation/range/dated_operation_range.rb +3 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +1 -1
- data/lib/zakuro/calculation/range/named_full_range.rb +3 -1
- data/lib/zakuro/calculation/range/named_operation_range.rb +3 -1
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +2 -1
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +10 -8
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +8 -34
- data/lib/zakuro/calculation/summary/internal/option.rb +51 -25
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +1 -1
- data/lib/zakuro/era/japan/calendar.rb +2 -2
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +1 -1
- data/lib/zakuro/era/japan/gengou/alignment.rb +14 -2
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +83 -25
- data/lib/zakuro/era/japan/gengou/resource/type.rb +81 -26
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +102 -23
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +1123 -375
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml +487 -163
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml +30 -10
- data/lib/zakuro/era/japan/gengou/resource.rb +16 -0
- data/lib/zakuro/era/japan/gengou.rb +7 -4
- data/lib/zakuro/era/western/calendar.rb +5 -11
- data/lib/zakuro/era/western/date_text.rb +40 -0
- data/lib/zakuro/gateway/locale/date.rb +2 -2
- data/lib/zakuro/operation/month/validator.rb +7 -1
- data/lib/zakuro/operation/yaml/month.yaml +15 -15
- data/lib/zakuro/output/logger.rb +21 -3
- data/lib/zakuro/tools/remainder_comparer.rb +97 -0
- metadata +7 -2
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../../monthly/meta/meta_collector'
|
4
|
+
|
5
|
+
require_relative '../../../tools/remainder_comparer'
|
6
|
+
|
3
7
|
# :nodoc:
|
4
8
|
module Zakuro
|
5
9
|
# :nodoc:
|
@@ -42,36 +46,6 @@ module Zakuro
|
|
42
46
|
annual_range
|
43
47
|
end
|
44
48
|
|
45
|
-
# :reek:TooManyStatements { max_statements: 7 }
|
46
|
-
|
47
|
-
class << self
|
48
|
-
#
|
49
|
-
# 月内(当月朔日から当月末日(来月朔日の前日)の間)に二十四節気があるか
|
50
|
-
# @note 大余60で一巡するため 以下2パターンがある
|
51
|
-
# * current_month <= next_month : (二十四節気) >= current_month && (二十四節気) < next_month
|
52
|
-
# * current_month > next_month : (二十四節気) >= current_month || (二十四節気) < next_month
|
53
|
-
#
|
54
|
-
# @param [Cycle::AbstractRemainder] solar_term 二十四節気
|
55
|
-
# @param [Cycle::AbstractRemainder] current_month 月初
|
56
|
-
# @param [Cycle::AbstractRemainder] next_month 月末
|
57
|
-
#
|
58
|
-
# @return [True] 対象の二十四節気がある
|
59
|
-
# @return [False] 対象の二十四節気がない
|
60
|
-
#
|
61
|
-
def in_solar_term?(solar_term:, current_month:, next_month:)
|
62
|
-
# 大余で比較する
|
63
|
-
target_time = solar_term.day
|
64
|
-
current_month_time = current_month.day
|
65
|
-
next_month_time = next_month.day
|
66
|
-
current_month_over = (target_time >= current_month_time)
|
67
|
-
next_month_under = (target_time < next_month_time)
|
68
|
-
|
69
|
-
return current_month_over && next_month_under if current_month_time <= next_month_time
|
70
|
-
|
71
|
-
current_month_over || next_month_under
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
49
|
private
|
76
50
|
|
77
51
|
# :reek:TooManyStatements { max_statements: 8 }
|
@@ -87,10 +61,10 @@ module Zakuro
|
|
87
61
|
# * 最大試行回数:4回(設定なし => 設定あり => 設定あり => 設定なし)
|
88
62
|
# * 閏月は1回しか設定しない
|
89
63
|
# * 最大2回設定する(中気・節気)
|
90
|
-
|
91
|
-
in_range =
|
92
|
-
|
93
|
-
|
64
|
+
4.times.each do |_index|
|
65
|
+
in_range = Tools::RemainderComparer.in_range?(
|
66
|
+
target: solar_term.remainder, start: current_month.remainder,
|
67
|
+
last: next_month.remainder
|
94
68
|
)
|
95
69
|
|
96
70
|
# 範囲外
|
@@ -34,17 +34,32 @@ module Zakuro
|
|
34
34
|
context = month.context
|
35
35
|
|
36
36
|
if context.option.dropped_date?
|
37
|
+
solar_term = month.solar_term_by_day(day: day.remainder.day)
|
38
|
+
|
37
39
|
remainder = day.remainder
|
38
|
-
solar_terms = month.solar_terms
|
39
40
|
option = dropped_date(
|
40
|
-
context: context, remainder: remainder,
|
41
|
+
context: context, remainder: remainder, solar_term: solar_term
|
41
42
|
)
|
42
43
|
options[Context::Option::DROPPED_DATE_KEY] = option
|
43
44
|
end
|
44
45
|
|
46
|
+
# TODO: refactor
|
45
47
|
if context.option.vanished_date?
|
46
48
|
remainder = day.remainder
|
47
49
|
average_remainder = month.first_day.average_remainder
|
50
|
+
# p "remainder: #{remainder.format}"
|
51
|
+
# p "last_average_remainder: #{month.meta.last_average_remainder.format}"
|
52
|
+
|
53
|
+
if day.number == 1
|
54
|
+
option = vanished_date(
|
55
|
+
context: context, remainder: remainder,
|
56
|
+
average_remainder: month.meta.last_average_remainder
|
57
|
+
)
|
58
|
+
options[Context::Option::VANISHED_DATE_KEY] = option
|
59
|
+
|
60
|
+
return options if option.matched
|
61
|
+
end
|
62
|
+
|
48
63
|
option = vanished_date(
|
49
64
|
context: context, remainder: remainder, average_remainder: average_remainder
|
50
65
|
)
|
@@ -61,40 +76,43 @@ module Zakuro
|
|
61
76
|
#
|
62
77
|
# @param [Context::Context] context 暦コンテキスト
|
63
78
|
# @param [Cycle::AbstractRemainder] remainder 当日和暦日
|
64
|
-
# @param [
|
79
|
+
# @param [Cycle::AbstractSolarTerm] solar_terms 二十四節気
|
65
80
|
#
|
66
81
|
# @return [Result::Data::Option::DroppedDate::Option] 没日
|
67
82
|
#
|
68
|
-
def dropped_date(context:, remainder:,
|
83
|
+
def dropped_date(context:, remainder:, solar_term:)
|
69
84
|
option = Result::Data::Option::DroppedDate::Option.new
|
70
85
|
|
71
86
|
return option if remainder.invalid?
|
72
87
|
|
73
88
|
location = Calculation::Option::DroppedDate::Location.new(
|
74
|
-
context: context,
|
89
|
+
context: context, solar_term: solar_term
|
75
90
|
)
|
76
91
|
|
92
|
+
return option if location.invalid?
|
93
|
+
|
77
94
|
return option unless location.exist?
|
78
95
|
|
79
96
|
dropped_date = location.get
|
80
97
|
|
81
|
-
|
82
|
-
|
83
|
-
|
98
|
+
dropped_date_option(
|
99
|
+
matched: remainder.day == dropped_date.day, location: location
|
100
|
+
)
|
84
101
|
end
|
85
102
|
|
86
103
|
#
|
87
104
|
# 没日オプション値を生成する
|
88
105
|
#
|
106
|
+
# @param [True, False] matched 没日有無
|
89
107
|
# @param [Calculation::Option::DroppedDate::Location] location 没日位置
|
90
108
|
#
|
91
109
|
# @return [Result::Data::Option::DroppedDate::Option] 没日オプション値
|
92
110
|
#
|
93
|
-
def dropped_date_option(location:)
|
111
|
+
def dropped_date_option(matched:, location:)
|
94
112
|
dropped_date = location.get
|
95
113
|
solar_term = location.solar_term
|
96
114
|
Result::Data::Option::DroppedDate::Option.new(
|
97
|
-
matched:
|
115
|
+
matched: matched,
|
98
116
|
calculation: Result::Data::Option::DroppedDate::Calculation.new(
|
99
117
|
remainder: dropped_date.format,
|
100
118
|
solar_term: Result::Data::SolarTerm.new(
|
@@ -108,41 +126,49 @@ module Zakuro
|
|
108
126
|
#
|
109
127
|
# 滅日を求める
|
110
128
|
#
|
111
|
-
# @param [
|
112
|
-
# @param [
|
113
|
-
# @param [
|
129
|
+
# @param [Context::Context] context 暦コンテキスト
|
130
|
+
# @param [Cycle::AbstractRemainder] remainder 当日和暦日
|
131
|
+
# @param [Cycle::AbstractRemainder] average_remainder 経朔
|
114
132
|
#
|
115
|
-
# @return [
|
133
|
+
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
116
134
|
#
|
117
135
|
def vanished_date(context:, remainder:, average_remainder:)
|
118
|
-
|
119
|
-
|
120
|
-
return option if average_remainder.invalid?
|
136
|
+
return Result::Data::Option::VanishedDate::Option.new if average_remainder.invalid?
|
121
137
|
|
122
138
|
location = Calculation::Option::VanishedDate::Location.new(
|
123
139
|
context: context, average_remainder: average_remainder
|
124
140
|
)
|
125
141
|
|
126
|
-
return
|
142
|
+
return Result::Data::Option::VanishedDate::Option.new if location.invalid?
|
127
143
|
|
128
|
-
|
144
|
+
unless location.exist?
|
145
|
+
# 結果確認のため経朔だけは設定する
|
146
|
+
return Result::Data::Option::VanishedDate::Option.new(
|
147
|
+
calculation: Result::Data::Option::VanishedDate::Calculation.new(
|
148
|
+
average_remainder: average_remainder
|
149
|
+
)
|
150
|
+
)
|
151
|
+
end
|
129
152
|
|
130
|
-
|
153
|
+
vanished_date = location.get
|
131
154
|
|
132
|
-
vanished_date_option(
|
155
|
+
vanished_date_option(
|
156
|
+
matched: remainder.day == vanished_date.day, location: location
|
157
|
+
)
|
133
158
|
end
|
134
159
|
|
135
160
|
#
|
136
161
|
# 滅日オプション値を生成する
|
137
162
|
#
|
138
|
-
# @param [
|
163
|
+
# @param [True, False] matched 滅日有無
|
164
|
+
# @param [Calculation::Option::VanishedDate::Location] location 滅日位置
|
139
165
|
#
|
140
|
-
# @return [Result::Data::Option::
|
166
|
+
# @return [Result::Data::Option::VanishedDate::Option] 滅日オプション値
|
141
167
|
#
|
142
|
-
def vanished_date_option(location:)
|
168
|
+
def vanished_date_option(matched:, location:)
|
143
169
|
vanished_date = location.get
|
144
170
|
Result::Data::Option::VanishedDate::Option.new(
|
145
|
-
matched:
|
171
|
+
matched: matched,
|
146
172
|
calculation: Result::Data::Option::VanishedDate::Calculation.new(
|
147
173
|
remainder: vanished_date.format,
|
148
174
|
average_remainder: location.average_remainder
|
@@ -98,7 +98,7 @@ module Zakuro
|
|
98
98
|
# @return [Calendar] 年月日情報(和暦)
|
99
99
|
#
|
100
100
|
def parse(regex: FORMAT, text: '')
|
101
|
-
return Calendar.new unless
|
101
|
+
return Calendar.new unless valid_date_text(regex: regex, text: text)
|
102
102
|
|
103
103
|
matched = text.match(regex)
|
104
104
|
|
@@ -120,7 +120,7 @@ module Zakuro
|
|
120
120
|
# @return [True] 正しい
|
121
121
|
# @return [True] 正しくない
|
122
122
|
#
|
123
|
-
def
|
123
|
+
def valid_date_text(regex: FORMAT, text: '')
|
124
124
|
return false unless text
|
125
125
|
|
126
126
|
matched = text.match(regex)
|
@@ -23,6 +23,9 @@ module Zakuro
|
|
23
23
|
# @return [Aligner] 整列結果
|
24
24
|
SUMMARY = Aligner.new(resources: Resource::LIST)
|
25
25
|
|
26
|
+
# @return [Aligner] 整列結果(運用値)
|
27
|
+
OPERATED_SUMMARY = Aligner.new(resources: Resource::OPERATED_LIST)
|
28
|
+
|
26
29
|
class << self
|
27
30
|
#
|
28
31
|
# 指定した範囲内の元号を取得する
|
@@ -30,11 +33,17 @@ module Zakuro
|
|
30
33
|
# @param [Integer] line 行
|
31
34
|
# @param [Western::Calendar] start_date 開始日
|
32
35
|
# @param [Western::Calendar] last_date 終了日
|
36
|
+
# @param [True, False] operated 運用値設定
|
33
37
|
#
|
34
38
|
# @return [Array<LinearGengou>] 元号
|
35
39
|
#
|
36
40
|
def get(line: FIRST_LINE,
|
37
|
-
start_date: Western::Calendar.new, last_date: Western::Calendar.new
|
41
|
+
start_date: Western::Calendar.new, last_date: Western::Calendar.new,
|
42
|
+
operated: false)
|
43
|
+
|
44
|
+
if operated
|
45
|
+
return OPERATED_SUMMARY.get(line: line, start_date: start_date, last_date: last_date)
|
46
|
+
end
|
38
47
|
|
39
48
|
SUMMARY.get(line: line, start_date: start_date, last_date: last_date)
|
40
49
|
end
|
@@ -44,10 +53,13 @@ module Zakuro
|
|
44
53
|
#
|
45
54
|
# @param [Integer] line 行
|
46
55
|
# @param [String] name 元号名
|
56
|
+
# @param [True, False] operated 運用値設定
|
47
57
|
#
|
48
58
|
# @return [Array<LinearGengou>] 元号
|
49
59
|
#
|
50
|
-
def get_by_name(line: FIRST_LINE, name:)
|
60
|
+
def get_by_name(line: FIRST_LINE, name:, operated: false)
|
61
|
+
return OPERATED_SUMMARY.get_by_name(line: line, name: name) if operated
|
62
|
+
|
51
63
|
SUMMARY.get_by_name(line: line, name: name)
|
52
64
|
end
|
53
65
|
end
|
@@ -30,9 +30,11 @@ module Zakuro
|
|
30
30
|
# @return [String] 元号名
|
31
31
|
attr_reader :name
|
32
32
|
# @return [Hash<String, String>] 開始年
|
33
|
-
attr_reader :
|
33
|
+
attr_reader :start_year
|
34
34
|
# @return [Hash<String, String>] 開始日
|
35
|
-
attr_reader :
|
35
|
+
attr_reader :start_date
|
36
|
+
# @return [True, False] 運用値
|
37
|
+
attr_reader :operated
|
36
38
|
|
37
39
|
#
|
38
40
|
# 初期化
|
@@ -40,11 +42,12 @@ module Zakuro
|
|
40
42
|
# @param [Hash<String, Strin>] hash 元号情報
|
41
43
|
# @param [Integer] index (元号セット内での)元号の要素位置
|
42
44
|
#
|
43
|
-
def initialize(hash:, index:)
|
45
|
+
def initialize(hash:, index:, operated: false)
|
44
46
|
@index = index
|
45
47
|
@name = hash['name']
|
46
|
-
@
|
47
|
-
@
|
48
|
+
@start_year = hash['start_year']
|
49
|
+
@start_date = hash['start_date']
|
50
|
+
@operated = operated
|
48
51
|
end
|
49
52
|
|
50
53
|
#
|
@@ -53,11 +56,11 @@ module Zakuro
|
|
53
56
|
# @return [Gengou] 元号情報
|
54
57
|
#
|
55
58
|
def create
|
56
|
-
|
57
|
-
|
59
|
+
year = Both::YearParser.new(hash: start_year).create
|
60
|
+
date = SwitchDateParser.new(hash: start_date, operated: operated).create
|
58
61
|
|
59
|
-
Gengou.new(name: name,
|
60
|
-
|
62
|
+
Gengou.new(name: name, start_year: year,
|
63
|
+
start_date: date)
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
@@ -70,23 +73,27 @@ module Zakuro
|
|
70
73
|
# @return [String] 元号セット名
|
71
74
|
attr_reader :name
|
72
75
|
# @return [Hash<String, String>] 終了年
|
73
|
-
attr_reader :
|
76
|
+
attr_reader :last_year
|
74
77
|
# @return [Hash<String, String>] 終了日
|
75
|
-
attr_reader :
|
78
|
+
attr_reader :last_date
|
76
79
|
# @return [Array<Hash<String, String>>] 元号情報
|
77
80
|
attr_reader :list
|
81
|
+
# @return [True, False] 運用値
|
82
|
+
attr_reader :operated
|
78
83
|
|
79
84
|
#
|
80
85
|
# 初期化
|
81
86
|
#
|
82
87
|
# @param [Hash<String, Object>] hash 元号セット情報
|
88
|
+
# @param [True, False] operated 運用値設定
|
83
89
|
#
|
84
|
-
def initialize(hash:)
|
90
|
+
def initialize(hash:, operated: false)
|
85
91
|
@id = hash['id']
|
86
92
|
@name = hash['name']
|
87
|
-
@
|
88
|
-
@
|
93
|
+
@last_year = hash['last_year']
|
94
|
+
@last_date = hash['last_date']
|
89
95
|
@list = hash['list']
|
96
|
+
@operated = operated
|
90
97
|
end
|
91
98
|
|
92
99
|
#
|
@@ -95,10 +102,10 @@ module Zakuro
|
|
95
102
|
# @return [Set] 元号セット情報
|
96
103
|
#
|
97
104
|
def create
|
98
|
-
|
105
|
+
date = SwitchDateParser.new(hash: last_date, operated: operated).create
|
99
106
|
list = create_list
|
100
107
|
Set.new(
|
101
|
-
id: id, name: name,
|
108
|
+
id: id, name: name, last_date: date, list: list
|
102
109
|
)
|
103
110
|
end
|
104
111
|
|
@@ -112,7 +119,9 @@ module Zakuro
|
|
112
119
|
def create_list
|
113
120
|
result = []
|
114
121
|
list.each_with_index do |li, index|
|
115
|
-
gengou = GengouParser.new(
|
122
|
+
gengou = GengouParser.new(
|
123
|
+
hash: li, index: index, operated: operated
|
124
|
+
).create
|
116
125
|
next_index = index + 1
|
117
126
|
gengou = calc_last_date_on_gengou_data(next_index: next_index,
|
118
127
|
gengou: gengou)
|
@@ -136,11 +145,15 @@ module Zakuro
|
|
136
145
|
return gengou
|
137
146
|
end
|
138
147
|
next_item = list[next_index]
|
148
|
+
next_start_date = SwitchDateParser.new(
|
149
|
+
hash: next_item['start_date'], operated: operated
|
150
|
+
).create
|
151
|
+
|
139
152
|
gengou.convert_next_start_year_to_last_year(
|
140
153
|
next_start_year: next_item['start_year']['western']
|
141
154
|
)
|
142
155
|
gengou.convert_next_start_date_to_last_date(
|
143
|
-
next_start_date:
|
156
|
+
next_start_date: next_start_date.western
|
144
157
|
)
|
145
158
|
gengou
|
146
159
|
end
|
@@ -153,9 +166,50 @@ module Zakuro
|
|
153
166
|
# @param [GengouParser] gengou 元号
|
154
167
|
#
|
155
168
|
def last_gengou_data(gengou:)
|
156
|
-
gengou.write_last_year(last_year:
|
157
|
-
|
158
|
-
|
169
|
+
gengou.write_last_year(last_year: last_year['western'])
|
170
|
+
|
171
|
+
date = SwitchDateParser.new(hash: last_date, operated: operated).create
|
172
|
+
|
173
|
+
gengou.write_last_date(last_date: date.western)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
#
|
178
|
+
# SwitchDateParser 切替日(運用/計算)
|
179
|
+
#
|
180
|
+
class SwitchDateParser
|
181
|
+
# @return [Hash<String, Strin>] 計算値
|
182
|
+
attr_reader :calculation
|
183
|
+
# @return [Hash<String, Strin>] 運用値
|
184
|
+
attr_reader :operation
|
185
|
+
# @return [True, False] 運用値
|
186
|
+
attr_reader :operated
|
187
|
+
|
188
|
+
#
|
189
|
+
# 初期化
|
190
|
+
#
|
191
|
+
# @param [Hash<String, Strin>] hash 切替日(運用/計算)
|
192
|
+
# @param [True, False] operated 運用値設定
|
193
|
+
#
|
194
|
+
def initialize(hash:, operated: false)
|
195
|
+
@calculation = hash['calculation']
|
196
|
+
@operation = hash['operation']
|
197
|
+
@operated = operated
|
198
|
+
end
|
199
|
+
|
200
|
+
#
|
201
|
+
# 切替日(運用/計算)情報を生成する
|
202
|
+
#
|
203
|
+
# @return [SwitchDate] 切替日(運用/計算)情報
|
204
|
+
#
|
205
|
+
def create
|
206
|
+
calculation_date = Both::DateParser.new(hash: calculation).create
|
207
|
+
operation_date = Both::DateParser.new(hash: operation).create
|
208
|
+
|
209
|
+
Japan::Gengou::Resource::SwitchDate.new(
|
210
|
+
calculation: calculation_date, operation: operation_date,
|
211
|
+
operated: operated
|
212
|
+
)
|
159
213
|
end
|
160
214
|
end
|
161
215
|
|
@@ -222,8 +276,11 @@ module Zakuro
|
|
222
276
|
# @return [Both::Date] 日情報
|
223
277
|
#
|
224
278
|
def create
|
225
|
-
japan_date = Japan::Calendar.
|
226
|
-
western_date = Western::Calendar.
|
279
|
+
japan_date = Japan::Calendar.new
|
280
|
+
western_date = Western::Calendar.new
|
281
|
+
|
282
|
+
japan_date = Japan::Calendar.parse(text: japan) unless japan == ''
|
283
|
+
western_date = Western::Calendar.parse(text: western) unless western == ''
|
227
284
|
|
228
285
|
Japan::Gengou::Resource::Both::Date.new(
|
229
286
|
japan: japan_date, western: western_date
|
@@ -237,19 +294,20 @@ module Zakuro
|
|
237
294
|
# 解析/展開する
|
238
295
|
#
|
239
296
|
# @param [String] filepath 元号セットファイルパス
|
297
|
+
# @param [True, False] operated 運用値設定
|
240
298
|
#
|
241
299
|
# @return [Set] 元号セット情報
|
242
300
|
#
|
243
301
|
# @raise [ArgumentError] 引数エラー
|
244
302
|
#
|
245
|
-
def run(filepath: '')
|
303
|
+
def run(filepath: '', operated: false)
|
246
304
|
yaml = YAML.load_file(filepath)
|
247
305
|
|
248
306
|
failed = Validator.run(yaml_hash: yaml)
|
249
307
|
|
250
308
|
raise ArgumentError, failed.join("\n") unless failed.empty?
|
251
309
|
|
252
|
-
parser = SetParser.new(hash: yaml)
|
310
|
+
parser = SetParser.new(hash: yaml, operated: operated)
|
253
311
|
parser.create
|
254
312
|
end
|
255
313
|
end
|