zakuro 0.6.1 → 0.8.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 +46 -17
- data/VERSION +1 -1
- data/doc/dropped_date.md +93 -0
- data/doc/error.md +45 -0
- data/doc/operation/transfer.rb +8 -8
- data/lib/zakuro/calculation/base/day.rb +52 -0
- data/lib/zakuro/calculation/base/gengou.rb +49 -3
- data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
- data/lib/zakuro/calculation/base/operated_year.rb +26 -24
- data/lib/zakuro/calculation/base/year.rb +7 -7
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
- data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
- data/lib/zakuro/calculation/era/gengou/{scroll.rb → abstract_scroll.rb} +44 -37
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
- data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
- data/lib/zakuro/calculation/era/gengou/internal/reserve/{list.rb → abstract_list.rb} +50 -64
- data/lib/zakuro/calculation/era/gengou/internal/reserve/{range.rb → abstract_range.rb} +73 -50
- 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 +156 -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 +73 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +23 -22
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
- data/lib/zakuro/calculation/era/version/version.rb +12 -10
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
- data/lib/zakuro/calculation/monthly/const.rb +18 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
- data/lib/zakuro/calculation/monthly/month.rb +55 -16
- data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
- data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
- data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
- data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
- data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
- data/lib/zakuro/calculation/range/{full_range.rb → abstract_full_range.rb} +45 -29
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +193 -0
- 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/medieval_annual_range.rb +64 -63
- 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_term.rb +220 -0
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
- data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
- data/lib/zakuro/calculation/{specifier → summary}/internal/month.rb +33 -12
- data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
- data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
- data/lib/zakuro/calculation/summary/japan/range.rb +179 -0
- data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +98 -0
- data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
- data/lib/zakuro/calculation/summary/western/range.rb +127 -0
- data/lib/zakuro/calculation/summary/western/single.rb +115 -0
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +173 -0
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +100 -0
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/calculation/type/optional.rb +46 -0
- data/lib/zakuro/condition.rb +143 -94
- data/lib/zakuro/context/context.rb +44 -0
- data/lib/zakuro/context/option.rb +119 -0
- data/lib/zakuro/context/version_class_resolver.rb +112 -0
- data/lib/zakuro/era/japan/calendar.rb +35 -33
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +93 -74
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +135 -133
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +143 -122
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +177 -168
- data/lib/zakuro/era/japan/gengou/alignment.rb +40 -25
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +199 -181
- data/lib/zakuro/era/japan/gengou/resource/type.rb +243 -234
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +257 -254
- data/lib/zakuro/era/japan/gengou/resource.rb +23 -22
- data/lib/zakuro/era/japan/gengou.rb +28 -41
- data/lib/zakuro/era/japan/version.rb +18 -16
- data/lib/zakuro/era/western/calendar.rb +104 -88
- data/lib/zakuro/exception/case/pattern.rb +71 -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 +39 -0
- data/lib/zakuro/exception/zakuro_error.rb +46 -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 +81 -0
- data/lib/zakuro/merchant.rb +67 -33
- data/lib/zakuro/operation/month/parser.rb +252 -249
- data/lib/zakuro/operation/month/type.rb +44 -35
- data/lib/zakuro/operation/month/validator.rb +182 -178
- data/lib/zakuro/operation/operation.rb +38 -36
- data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
- data/lib/zakuro/output/logger.rb +17 -3
- data/lib/zakuro/output/response.rb +107 -141
- 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/option/abstract_option.rb +37 -0
- data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
- data/lib/zakuro/result/data/single_day.rb +56 -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/history.rb +54 -0
- data/lib/zakuro/result/operation/month.rb +31 -0
- data/lib/zakuro/result/operation.rb +22 -97
- data/lib/zakuro/result/result.rb +6 -4
- data/lib/zakuro/tools/stringifier.rb +67 -42
- data/lib/zakuro/tools/typeconv.rb +17 -15
- data/lib/zakuro/tools/typeof.rb +15 -13
- data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
- data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
- data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
- data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
- data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
- data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/senmyou/const/remainder.rb +5 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
- data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
- data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
- metadata +68 -16
- data/lib/zakuro/calculation/range/operated_range.rb +0 -193
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -220
- 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/version/context.rb +0 -44
- data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -6,284 +6,293 @@ require_relative '../../calendar'
|
|
6
6
|
|
7
7
|
# :nodoc:
|
8
8
|
module Zakuro
|
9
|
-
#
|
10
|
-
# Japan 和暦
|
11
|
-
#
|
9
|
+
# :nodoc:
|
12
10
|
module Japan
|
13
|
-
#
|
14
|
-
|
15
|
-
#
|
16
|
-
module Resource
|
11
|
+
# :nodoc:
|
12
|
+
module Gengou
|
17
13
|
#
|
18
|
-
#
|
14
|
+
# Resource yaml解析結果
|
19
15
|
#
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
16
|
+
module Resource
|
17
|
+
#
|
18
|
+
# Gengou 元号情報
|
19
|
+
#
|
20
|
+
class Gengou
|
21
|
+
# @return [String] 元号名
|
22
|
+
attr_reader :name
|
23
|
+
# @return [Both::Year] 開始年(和暦/西暦)
|
24
|
+
attr_reader :both_start_year
|
25
|
+
# @return [Both::Date] 開始日(和暦/西暦)
|
26
|
+
attr_reader :both_start_date
|
27
|
+
# @return [Integer] 終了年
|
28
|
+
attr_reader :last_year
|
29
|
+
# @return [Western::Calendar] 終了日
|
30
|
+
attr_reader :last_date
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# 終了年を更新する
|
54
|
-
#
|
55
|
-
# @param [Integer] last_year 終了年
|
56
|
-
#
|
57
|
-
def write_last_year(last_year:)
|
58
|
-
unless Gengou.valid_year(year: last_year)
|
59
|
-
raise ArgumentError, "invalid year format. [#{last_year}]"
|
32
|
+
#
|
33
|
+
# 初期化
|
34
|
+
#
|
35
|
+
# @param [String] name 元号名
|
36
|
+
# @param [Both::Year] both_start_year 開始年(和暦/西暦)
|
37
|
+
# @param [Both::Date] both_start_date 開始日(和暦/西暦)
|
38
|
+
# @param [Integer] last_date 終了年
|
39
|
+
# @param [Western::Calendar] last_date 終了日
|
40
|
+
#
|
41
|
+
def initialize(name: '', both_start_year: Both::Year.new,
|
42
|
+
both_start_date: Both::Date.new,
|
43
|
+
last_date: Western::Calendar.new,
|
44
|
+
last_year: Both::Year::INVALID)
|
45
|
+
@name = name
|
46
|
+
@both_start_year = both_start_year
|
47
|
+
@both_start_date = both_start_date
|
48
|
+
@last_year = last_year
|
49
|
+
@last_date = last_date
|
60
50
|
end
|
61
51
|
|
62
|
-
|
63
|
-
|
52
|
+
#
|
53
|
+
# 終了年を更新する
|
54
|
+
#
|
55
|
+
# @param [Integer] last_year 終了年
|
56
|
+
#
|
57
|
+
# @raise [ArgumentError] 引数エラー
|
58
|
+
#
|
59
|
+
def write_last_year(last_year:)
|
60
|
+
unless Gengou.valid_year(year: last_year)
|
61
|
+
raise ArgumentError, "invalid year format. [#{last_year}]"
|
62
|
+
end
|
64
63
|
|
65
|
-
|
66
|
-
# 終了日を更新する
|
67
|
-
#
|
68
|
-
# @param [Western::Calendar] last_date 終了日
|
69
|
-
#
|
70
|
-
def write_last_date(last_date:)
|
71
|
-
unless Gengou.valid_date(date: last_date)
|
72
|
-
raise ArgumentError, "invalid date format. [#{last_date}]"
|
64
|
+
@last_year = last_year
|
73
65
|
end
|
74
66
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
#
|
87
|
-
def self.valid_year(year:)
|
88
|
-
return false unless year
|
67
|
+
#
|
68
|
+
# 終了日を更新する
|
69
|
+
#
|
70
|
+
# @param [Western::Calendar] last_date 終了日
|
71
|
+
#
|
72
|
+
# @raise [ArgumentError] 引数エラー
|
73
|
+
#
|
74
|
+
def write_last_date(last_date:)
|
75
|
+
unless Gengou.valid_date(date: last_date)
|
76
|
+
raise ArgumentError, "invalid date format. [#{last_date}]"
|
77
|
+
end
|
89
78
|
|
90
|
-
|
91
|
-
|
79
|
+
@last_date = last_date
|
80
|
+
nil
|
81
|
+
end
|
92
82
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
83
|
+
#
|
84
|
+
# 次の元号の開始年から、元号の終了年に変換する
|
85
|
+
#
|
86
|
+
# @param [Integer] next_start_year 次回開始年
|
87
|
+
#
|
88
|
+
def convert_next_start_year_to_last_year(next_start_year:)
|
89
|
+
if both_start_year.western >= next_start_year
|
90
|
+
@last_year = next_start_year
|
91
|
+
return
|
92
|
+
end
|
103
93
|
|
104
|
-
|
105
|
-
end
|
94
|
+
@last_year = next_start_year - 1
|
106
95
|
|
107
|
-
|
108
|
-
# 次の元号の開始年から、元号の終了年に変換する
|
109
|
-
#
|
110
|
-
# @param [Integer] next_start_year 次回開始年
|
111
|
-
#
|
112
|
-
def convert_next_start_year_to_last_year(next_start_year:)
|
113
|
-
if @both_start_year.western >= next_start_year
|
114
|
-
@last_year = next_start_year
|
115
|
-
return
|
96
|
+
nil
|
116
97
|
end
|
117
98
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
99
|
+
#
|
100
|
+
# 次の元号の開始日から、元号の終了日に変換する
|
101
|
+
#
|
102
|
+
# @param [String] next_start_date 次回開始日
|
103
|
+
#
|
104
|
+
# @raise [ArgumentError] 引数エラー
|
105
|
+
#
|
106
|
+
def convert_next_start_date_to_last_date(next_start_date: '')
|
107
|
+
raise ArgumentError, 'empty string cannot convert' if next_start_date.empty?
|
122
108
|
|
123
|
-
|
124
|
-
|
125
|
-
#
|
126
|
-
# @param [String] next_start_date 次回開始日
|
127
|
-
#
|
128
|
-
def convert_next_start_date_to_last_date(next_start_date: '')
|
129
|
-
raise ArgumentError, 'empty string cannot convert' if next_start_date.empty?
|
109
|
+
start_date = Western::Calendar.parse(text: next_start_date)
|
110
|
+
@last_date = start_date - 1
|
130
111
|
|
131
|
-
|
132
|
-
|
112
|
+
nil
|
113
|
+
end
|
133
114
|
|
134
|
-
|
135
|
-
|
115
|
+
#
|
116
|
+
# 指定した日が元号に含まれるか
|
117
|
+
#
|
118
|
+
# @param [Western::Calendar] date 日
|
119
|
+
#
|
120
|
+
# @return [True] 含まれる
|
121
|
+
# @return [False] 含まれない
|
122
|
+
#
|
123
|
+
def include?(date:)
|
124
|
+
date >= both_start_date.western && date <= last_date
|
125
|
+
end
|
136
126
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
127
|
+
#
|
128
|
+
# 不正か
|
129
|
+
#
|
130
|
+
# @return [True] 不正
|
131
|
+
# @return [False] 不正なし
|
132
|
+
#
|
133
|
+
def invalid?
|
134
|
+
both_start_year.japan == -1 || both_start_year.invalid? ||
|
135
|
+
both_start_date.invalid? || last_date.invalid?
|
136
|
+
end
|
148
137
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
138
|
+
#
|
139
|
+
# 1元号年を追加する
|
140
|
+
#
|
141
|
+
# def next_year
|
142
|
+
# @year += 1 unless invalid?
|
143
|
+
# nil
|
144
|
+
# end
|
145
|
+
|
146
|
+
def to_s
|
147
|
+
"name: #{@name}, both_start_year: #{both_start_year.format}, " \
|
148
|
+
"both_start_date: #{both_start_date.format}, last_date: #{last_date.format}"
|
149
|
+
end
|
159
150
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
151
|
+
class << self
|
152
|
+
#
|
153
|
+
# 年が不正なしかどうかを確認する
|
154
|
+
#
|
155
|
+
# @param [Integer] year 年
|
156
|
+
#
|
157
|
+
# @return [True] 不正なし
|
158
|
+
# @return [False] 不正
|
159
|
+
#
|
160
|
+
def valid_year(year:)
|
161
|
+
return false unless year
|
162
|
+
|
163
|
+
year.is_a?(Integer)
|
164
|
+
end
|
165
|
+
|
166
|
+
#
|
167
|
+
# 日付が不正なしかどうかを確認する
|
168
|
+
#
|
169
|
+
# @param [Western::Calendar] date 日付
|
170
|
+
#
|
171
|
+
# @return [True] 不正なし
|
172
|
+
# @return [False] 不正
|
173
|
+
#
|
174
|
+
def valid_date(date:)
|
175
|
+
return false unless date
|
176
|
+
|
177
|
+
date.is_a?(Western::Calendar)
|
178
|
+
end
|
179
|
+
end
|
171
180
|
end
|
172
|
-
end
|
173
181
|
|
174
|
-
#
|
175
|
-
# Set 元号セット
|
176
|
-
#
|
177
|
-
class Set
|
178
|
-
# @return [Integer] 不正値
|
179
|
-
INVALID = -1
|
180
|
-
# @return [Integer] 元号セットID
|
181
|
-
attr_reader :id
|
182
|
-
# @return [String] 元号セット名
|
183
|
-
attr_reader :name
|
184
|
-
# @return [Both::Date] 元号セットでの終了年
|
185
|
-
attr_reader :both_last_year
|
186
|
-
# @return [Both::Date] 元号セットでの終了日
|
187
|
-
attr_reader :both_last_date
|
188
|
-
# @return [Array<Gengou>] 元号リスト
|
189
|
-
attr_reader :list
|
190
|
-
|
191
|
-
#
|
192
|
-
# 初期化
|
193
182
|
#
|
194
|
-
#
|
195
|
-
# @param [String] name 元号セット名
|
196
|
-
# @param [Western::Calendar] last_date 元号セットでの終了日
|
197
|
-
# @param [Array<Gengou>] list 元号リスト
|
183
|
+
# Set 元号セット
|
198
184
|
#
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
@
|
203
|
-
|
204
|
-
@
|
205
|
-
|
206
|
-
|
185
|
+
class Set
|
186
|
+
# @return [Integer] 不正値
|
187
|
+
INVALID = -1
|
188
|
+
# @return [Integer] 元号セットID
|
189
|
+
attr_reader :id
|
190
|
+
# @return [String] 元号セット名
|
191
|
+
attr_reader :name
|
192
|
+
# @return [Both::Date] 元号セットでの終了年
|
193
|
+
attr_reader :both_last_year
|
194
|
+
# @return [Both::Date] 元号セットでの終了日
|
195
|
+
attr_reader :both_last_date
|
196
|
+
# @return [Array<Gengou>] 元号リスト
|
197
|
+
attr_reader :list
|
207
198
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
199
|
+
#
|
200
|
+
# 初期化
|
201
|
+
#
|
202
|
+
# @param [Integer] id 元号セットID
|
203
|
+
# @param [String] name 元号セット名
|
204
|
+
# @param [Western::Calendar] last_date 元号セットでの終了日
|
205
|
+
# @param [Array<Gengou>] list 元号リスト
|
206
|
+
#
|
207
|
+
def initialize(id: INVALID, name: '', both_last_year: Both::Year.new,
|
208
|
+
both_last_date: Both::Date.new, list: [])
|
209
|
+
@id = id
|
210
|
+
@name = name
|
211
|
+
@both_last_year = both_last_year
|
212
|
+
@both_last_date = both_last_date
|
213
|
+
@list = list
|
218
214
|
end
|
219
215
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
end
|
232
|
-
end
|
216
|
+
#
|
217
|
+
# 指定した日付を含む元号を返す
|
218
|
+
#
|
219
|
+
# @param [Western::Calendar] date 日
|
220
|
+
#
|
221
|
+
# @return [Gengou] 元号
|
222
|
+
#
|
223
|
+
def include_item(date:)
|
224
|
+
list.each do |item|
|
225
|
+
return item if item.include?(date: date)
|
226
|
+
end
|
233
227
|
|
234
|
-
|
235
|
-
# 和暦/西暦
|
236
|
-
#
|
237
|
-
module Both
|
238
|
-
#
|
239
|
-
# Year 年
|
240
|
-
#
|
241
|
-
class Year
|
242
|
-
# @return [Integer] 不正値
|
243
|
-
INVALID = -1
|
244
|
-
# @return [Integer] 和暦元号年
|
245
|
-
attr_reader :japan
|
246
|
-
# @return [Integer] 西暦年
|
247
|
-
attr_reader :western
|
248
|
-
|
249
|
-
def initialize(japan: INVALID, western: INVALID)
|
250
|
-
@japan = japan
|
251
|
-
@western = western
|
228
|
+
Gengou.new
|
252
229
|
end
|
253
230
|
|
254
231
|
#
|
255
|
-
#
|
232
|
+
# 元号セットが不正かどうかを確認する
|
256
233
|
#
|
257
|
-
# @return [True]
|
258
|
-
# @return [False]
|
234
|
+
# @return [True] 正しくない
|
235
|
+
# @return [False] 正しい
|
259
236
|
#
|
260
237
|
def invalid?
|
261
|
-
@
|
238
|
+
@id == INVALID
|
262
239
|
end
|
263
240
|
end
|
264
241
|
|
265
242
|
#
|
266
|
-
#
|
243
|
+
# 和暦/西暦
|
267
244
|
#
|
268
|
-
|
269
|
-
#
|
270
|
-
|
271
|
-
#
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
@
|
276
|
-
|
245
|
+
module Both
|
246
|
+
#
|
247
|
+
# Year 年
|
248
|
+
#
|
249
|
+
class Year
|
250
|
+
# @return [Integer] 不正値
|
251
|
+
INVALID = -1
|
252
|
+
# @return [Integer] 和暦元号年
|
253
|
+
attr_reader :japan
|
254
|
+
# @return [Integer] 西暦年
|
255
|
+
attr_reader :western
|
256
|
+
|
257
|
+
def initialize(japan: INVALID, western: INVALID)
|
258
|
+
@japan = japan
|
259
|
+
@western = western
|
260
|
+
end
|
261
|
+
|
262
|
+
#
|
263
|
+
# 不正か
|
264
|
+
#
|
265
|
+
# @return [True] 不正
|
266
|
+
# @return [False] 不正なし
|
267
|
+
#
|
268
|
+
def invalid?
|
269
|
+
japan == INVALID || western == INVALID
|
270
|
+
end
|
277
271
|
end
|
278
272
|
|
279
273
|
#
|
280
|
-
#
|
274
|
+
# Date 日
|
281
275
|
#
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
276
|
+
class Date
|
277
|
+
# @return [Japan::Calendar] 和暦日
|
278
|
+
attr_reader :japan
|
279
|
+
# @return [Western::Calendar] 西暦日
|
280
|
+
attr_reader :western
|
281
|
+
|
282
|
+
def initialize(japan: Japan::Calendar.new, western: Western::Calendar.new)
|
283
|
+
@japan = japan
|
284
|
+
@western = western
|
285
|
+
end
|
286
|
+
|
287
|
+
#
|
288
|
+
# 不正か
|
289
|
+
#
|
290
|
+
# @return [True] 不正
|
291
|
+
# @return [False] 不正なし
|
292
|
+
#
|
293
|
+
def invalid?
|
294
|
+
japan.invalid? || western.invalid?
|
295
|
+
end
|
287
296
|
end
|
288
297
|
end
|
289
298
|
end
|