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
@@ -9,174 +9,177 @@ module Zakuro
|
|
9
9
|
# :nodoc:
|
10
10
|
module Japan
|
11
11
|
# :nodoc:
|
12
|
-
module
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
#
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
12
|
+
module Gengou
|
13
|
+
# :nodoc:
|
14
|
+
module Alignment
|
15
|
+
#
|
16
|
+
# LinearGengou 直列元号
|
17
|
+
#
|
18
|
+
class LinearGengou
|
19
|
+
INVALID_YEAR = -1
|
20
|
+
|
21
|
+
# @return [Western::Calendar] 開始日
|
22
|
+
attr_reader :start_date
|
23
|
+
# @return [Western::Calendar] 終了日
|
24
|
+
attr_reader :last_date
|
25
|
+
# @return [Gengou] 元号
|
26
|
+
attr_reader :gengou
|
27
|
+
|
28
|
+
#
|
29
|
+
# 初期化
|
30
|
+
#
|
31
|
+
# @param [Western::Calendar] start_date 開始日
|
32
|
+
# @param [Western::Calendar] last_date 終了日
|
33
|
+
# @param [Resource::Gengou] gengou 元号
|
34
|
+
#
|
35
|
+
def initialize(start_date: Western::Calendar.new, last_date: Western::Calendar.new,
|
36
|
+
gengou: Resource::Gengou.new)
|
37
|
+
@gengou = gengou
|
38
|
+
@start_date = start_date.invalid? ? native_start_date : start_date
|
39
|
+
@last_date = last_date.invalid? ? native_last_date : last_date
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# 元号名を取得する
|
44
|
+
#
|
45
|
+
# @return [String] 元号名
|
46
|
+
#
|
47
|
+
def name
|
48
|
+
@gengou.name
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# 不正か
|
53
|
+
#
|
54
|
+
# @return [True] 不正
|
55
|
+
# @return [False] 不正なし
|
56
|
+
#
|
57
|
+
def invalid?
|
58
|
+
@gengou.invalid?
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# 範囲内か
|
63
|
+
#
|
64
|
+
# @param [Western::Calendar] date 西暦日
|
65
|
+
#
|
66
|
+
# @return [True] 範囲内
|
67
|
+
# @return [False] 範囲外
|
68
|
+
#
|
69
|
+
def include?(date: Western::Calendar.new)
|
70
|
+
return false if invalid?
|
71
|
+
|
72
|
+
return false if @start_date.invalid?
|
73
|
+
|
74
|
+
return false if @last_date.invalid?
|
75
|
+
|
76
|
+
return false if date < @start_date
|
77
|
+
|
78
|
+
return false if date > @last_date
|
79
|
+
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# 完全に範囲内か
|
85
|
+
#
|
86
|
+
# @param [Western::Calendar] start_date 開始日
|
87
|
+
# @param [Western::Calendar] last_date 終了日
|
88
|
+
#
|
89
|
+
# @return [True] 範囲内
|
90
|
+
# @return [False] 範囲外あり
|
91
|
+
#
|
92
|
+
def in?(start_date:, last_date:)
|
93
|
+
@start_date <= start_date && last_date <= @last_date
|
94
|
+
end
|
95
|
+
|
96
|
+
#
|
97
|
+
# 完全に範囲外か
|
98
|
+
#
|
99
|
+
# @param [Western::Calendar] start_date 開始日
|
100
|
+
# @param [Western::Calendar] last_date 終了日
|
101
|
+
#
|
102
|
+
# @return [True] 範囲外
|
103
|
+
# @return [False] 範囲内あり
|
104
|
+
#
|
105
|
+
def out?(start_date:, last_date:)
|
106
|
+
# 範囲より前
|
107
|
+
return true if start_date < @start_date && last_date < @start_date
|
108
|
+
|
109
|
+
# 範囲より後
|
110
|
+
return true if @last_date < start_date && @last_date < last_date
|
111
|
+
|
112
|
+
false
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# 完全に範囲を超えているか
|
117
|
+
#
|
118
|
+
# @param [Western::Calendar] start_date 開始日
|
119
|
+
# @param [Western::Calendar] last_date 終了日
|
120
|
+
#
|
121
|
+
# @return [True] 完全超過
|
122
|
+
# @return [True] 完全超過せず
|
123
|
+
#
|
124
|
+
def covered?(start_date:, last_date:)
|
125
|
+
start_date < @start_date && @last_date < last_date
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# 元は1繋ぎであった元号が別の行に存在するか(設定値から変更されているか)?
|
130
|
+
#
|
131
|
+
# @return [True] 存在する
|
132
|
+
# @return [False] 存在しない
|
133
|
+
#
|
134
|
+
def changed?
|
135
|
+
return true if change_start_date?
|
136
|
+
|
137
|
+
return true if change_last_date?
|
138
|
+
|
139
|
+
false
|
140
|
+
end
|
141
|
+
|
142
|
+
#
|
143
|
+
# 開始日が設定された開始日と異なるか(行が変更されているか)
|
144
|
+
#
|
145
|
+
# @return [True] 異なる
|
146
|
+
# @return [False] 同一
|
147
|
+
#
|
148
|
+
def change_start_date?
|
149
|
+
return false if invalid?
|
150
|
+
|
151
|
+
@start_date != native_start_date
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# 終了日が設定された終了日と異なるか(行が変更されているか)
|
156
|
+
#
|
157
|
+
# @return [True] 異なる
|
158
|
+
# @return [False] 同一
|
159
|
+
#
|
160
|
+
def change_last_date?
|
161
|
+
return false if invalid?
|
162
|
+
|
163
|
+
@last_date != native_last_date
|
164
|
+
end
|
165
|
+
|
166
|
+
#
|
167
|
+
# 設定された元号の開始日を取得する
|
168
|
+
#
|
169
|
+
# @return [Western::Calendar]設定された元号の開始日
|
170
|
+
#
|
171
|
+
def native_start_date
|
172
|
+
@gengou.both_start_date.western
|
173
|
+
end
|
174
|
+
|
175
|
+
#
|
176
|
+
# 設定された元号の終了日を取得する
|
177
|
+
#
|
178
|
+
# @return [Western::Calendar] 設定された元号の終了日
|
179
|
+
#
|
180
|
+
def native_last_date
|
181
|
+
@gengou.last_date
|
182
|
+
end
|
180
183
|
end
|
181
184
|
end
|
182
185
|
end
|
@@ -6,36 +6,49 @@ require_relative './resource'
|
|
6
6
|
|
7
7
|
# :nodoc:
|
8
8
|
module Zakuro
|
9
|
-
#
|
10
|
-
# Japan 和暦
|
11
|
-
#
|
9
|
+
# :nodoc:
|
12
10
|
module Japan
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
|
11
|
+
# :nodoc:
|
12
|
+
module Gengou
|
13
|
+
#
|
14
|
+
# Alignment 整列
|
15
|
+
#
|
16
|
+
module Alignment
|
17
|
+
# @return [Integer] 1行目元号
|
18
|
+
FIRST_LINE = Aligner::FIRST_LINE
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
# @return [Integer] 2行目元号
|
21
|
+
SECOND_LINE = Aligner::SECOND_LINE
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
# @return [Aligner] 整列結果
|
24
|
+
SUMMARY = Aligner.new(resources: Resource::LIST)
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
#
|
27
|
+
# 指定した範囲内の元号を取得する
|
28
|
+
#
|
29
|
+
# @param [Integer] line 行
|
30
|
+
# @param [Western::Calendar] start_date 開始日
|
31
|
+
# @param [Western::Calendar] last_date 終了日
|
32
|
+
#
|
33
|
+
# @return [Array<LinearGengou>] 元号
|
34
|
+
#
|
35
|
+
def self.get(line: FIRST_LINE,
|
36
|
+
start_date: Western::Calendar.new, last_date: Western::Calendar.new)
|
37
|
+
|
38
|
+
SUMMARY.get(line: line, start_date: start_date, last_date: last_date)
|
39
|
+
end
|
37
40
|
|
38
|
-
|
41
|
+
#
|
42
|
+
# 指定した範囲内の元号を取得する(元号名)
|
43
|
+
#
|
44
|
+
# @param [Integer] line 行
|
45
|
+
# @param [String] name 元号名
|
46
|
+
#
|
47
|
+
# @return [Array<LinearGengou>] 元号
|
48
|
+
#
|
49
|
+
def self.get_by_name(line: FIRST_LINE, name:)
|
50
|
+
SUMMARY.get_by_name(line: line, name: name)
|
51
|
+
end
|
39
52
|
end
|
40
53
|
end
|
41
54
|
end
|