zakuro 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -13
- data/VERSION +1 -1
- data/doc/dropped_date.md +93 -0
- data/doc/error.md +45 -0
- data/doc/operation/csv/month.csv +100 -79
- data/doc/operation/operation.xlsx +0 -0
- data/lib/zakuro/calculation/base/day.rb +52 -0
- data/lib/zakuro/calculation/base/gengou.rb +5 -5
- 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/abstract_scroll.rb +38 -29
- 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/abstract_list.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
- 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 +17 -17
- 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/abstract_full_range.rb +40 -25
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +111 -109
- data/lib/zakuro/calculation/range/dated_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/dated_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/named_operation_range.rb +1 -1
- 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/summary/internal/month.rb +32 -11
- 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 +145 -118
- data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +57 -50
- data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
- data/lib/zakuro/calculation/summary/western/range.rb +95 -92
- data/lib/zakuro/calculation/summary/western/single.rb +78 -76
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -119
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +63 -56
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/calculation/type/optional.rb +46 -0
- data/lib/zakuro/condition.rb +142 -92
- 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 +8 -4
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
- data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -34
- data/lib/zakuro/era/japan/gengou/resource/type.rb +45 -37
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
- data/lib/zakuro/era/japan/gengou.rb +28 -26
- 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 +39 -3
- data/lib/zakuro/exception/case/preset.rb +2 -2
- data/lib/zakuro/exception/exception.rb +17 -15
- data/lib/zakuro/exception/zakuro_error.rb +19 -1
- data/lib/zakuro/gateway/locale/date.rb +2 -2
- data/lib/zakuro/gateway/locale/range.rb +3 -3
- data/lib/zakuro/gateway/range.rb +3 -3
- data/lib/zakuro/gateway/single.rb +14 -3
- data/lib/zakuro/merchant.rb +79 -9
- data/lib/zakuro/operation/month/parser.rb +252 -249
- data/lib/zakuro/operation/month/type.rb +17 -8
- data/lib/zakuro/operation/month/validator.rb +148 -144
- data/lib/zakuro/operation/operation.rb +38 -36
- data/lib/zakuro/operation/yaml/month.yaml +955 -281
- data/lib/zakuro/output/response.rb +107 -141
- 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 +9 -1
- data/lib/zakuro/result/operation/month/annotation.rb +2 -2
- data/lib/zakuro/result/operation/month/history.rb +2 -2
- data/lib/zakuro/result/operation/month.rb +31 -0
- data/lib/zakuro/result/operation.rb +39 -0
- data/lib/zakuro/result/result.rb +3 -3
- 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 +7 -1
- 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 +27 -7
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
- data/lib/zakuro/result/operation/month/bundle.rb +0 -36
- data/lib/zakuro/result/operation/operation.rb +0 -44
- data/lib/zakuro/version/context.rb +0 -44
- data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -41,7 +41,7 @@ module Zakuro
|
|
41
41
|
def initialize(resources: [])
|
42
42
|
@lines = []
|
43
43
|
(1..LINE_SIZE).each do |_index|
|
44
|
-
|
44
|
+
lines.push(Line.new)
|
45
45
|
end
|
46
46
|
|
47
47
|
save(resources: resources)
|
@@ -68,10 +68,12 @@ module Zakuro
|
|
68
68
|
#
|
69
69
|
# @return [Array<LinearGengou>] 元号
|
70
70
|
#
|
71
|
+
# @raise [ArgumentError] 引数エラー
|
72
|
+
#
|
71
73
|
def get(line:, start_date:, last_date:)
|
72
74
|
raise ArgumentError.new, 'invalid line number' unless LINE_INDEXES.include?(line)
|
73
75
|
|
74
|
-
|
76
|
+
lines[line].get(start_date: start_date, last_date: last_date)
|
75
77
|
end
|
76
78
|
|
77
79
|
#
|
@@ -82,10 +84,12 @@ module Zakuro
|
|
82
84
|
#
|
83
85
|
# @return [Array<LinearGengou>] 元号
|
84
86
|
#
|
87
|
+
# @raise [ArgumentError] 引数エラー
|
88
|
+
#
|
85
89
|
def get_by_name(line:, name:)
|
86
90
|
raise ArgumentError.new, 'invalid line number' unless LINE_INDEXES.include?(line)
|
87
91
|
|
88
|
-
|
92
|
+
lines[line].get_by_name(name: name)
|
89
93
|
end
|
90
94
|
|
91
95
|
private
|
@@ -110,7 +114,7 @@ module Zakuro
|
|
110
114
|
rest = [
|
111
115
|
LinearGengou.new(gengou: gengou)
|
112
116
|
]
|
113
|
-
|
117
|
+
lines.each do |line|
|
114
118
|
rest = line.push(list: rest)
|
115
119
|
end
|
116
120
|
end
|
@@ -14,153 +14,152 @@ module Zakuro
|
|
14
14
|
# Division 元号区分
|
15
15
|
#
|
16
16
|
module Division
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if other.out?(start_date: this.start_date, last_date: this.last_date)
|
33
|
-
# 該当なし
|
34
|
-
return result
|
35
|
-
end
|
17
|
+
class << self
|
18
|
+
#
|
19
|
+
# 重複した範囲を返す
|
20
|
+
#
|
21
|
+
# @param [LinearGengou] this 残り元号
|
22
|
+
# @param [LinearGengou] other 比較元号
|
23
|
+
#
|
24
|
+
# @return [Array<LinearGengou>] 重複分
|
25
|
+
#
|
26
|
+
def match(this:, other:)
|
27
|
+
result = []
|
28
|
+
if other.in?(start_date: this.start_date, last_date: this.last_date)
|
29
|
+
result.push(this)
|
30
|
+
return result
|
31
|
+
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
33
|
+
if other.out?(start_date: this.start_date, last_date: this.last_date)
|
34
|
+
# 該当なし
|
35
|
+
return result
|
36
|
+
end
|
42
37
|
|
43
|
-
|
38
|
+
if other.covered?(start_date: this.start_date, last_date: this.last_date)
|
39
|
+
# 範囲内のみ返す
|
40
|
+
result.push(trim_gengou(this: this, other: other))
|
41
|
+
return result
|
42
|
+
end
|
44
43
|
|
45
|
-
|
46
|
-
end
|
44
|
+
result.push(narrow_gengou(this: this, other: other))
|
47
45
|
|
48
|
-
|
49
|
-
# 範囲が重複しない差分を返す
|
50
|
-
#
|
51
|
-
# @param [LinearGengou] this 積元号
|
52
|
-
# @param [LinearGengou] other 比較元号
|
53
|
-
#
|
54
|
-
# @return [Array<LinearGengou>] 差分
|
55
|
-
#
|
56
|
-
def self.mismatch(this:, other:)
|
57
|
-
result = []
|
58
|
-
if other.in?(start_date: this.start_date, last_date: this.last_date)
|
59
|
-
# 該当なし
|
60
|
-
return result
|
46
|
+
result
|
61
47
|
end
|
62
48
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
49
|
+
#
|
50
|
+
# 範囲が重複しない差分を返す
|
51
|
+
#
|
52
|
+
# @param [LinearGengou] this 積元号
|
53
|
+
# @param [LinearGengou] other 比較元号
|
54
|
+
#
|
55
|
+
# @return [Array<LinearGengou>] 差分
|
56
|
+
#
|
57
|
+
def mismatch(this:, other:)
|
58
|
+
result = []
|
59
|
+
if other.in?(start_date: this.start_date, last_date: this.last_date)
|
60
|
+
# 該当なし
|
61
|
+
return result
|
62
|
+
end
|
72
63
|
|
73
|
-
|
74
|
-
|
75
|
-
|
64
|
+
if other.out?(start_date: this.start_date, last_date: this.last_date)
|
65
|
+
result.push(this)
|
66
|
+
return result
|
67
|
+
end
|
76
68
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
# @param [Array<LinearGengou>] list 元号
|
81
|
-
#
|
82
|
-
# @return [Array<LinearGengou>] 同一元号がつながった元号
|
83
|
-
#
|
84
|
-
def self.connect(list: []) # rubocop:disable Metrics/MethodLength
|
85
|
-
result = []
|
86
|
-
list.each do |linear_gengou|
|
87
|
-
if result.size.zero?
|
88
|
-
result.push(linear_gengou)
|
89
|
-
next
|
69
|
+
if other.covered?(start_date: this.start_date, last_date: this.last_date)
|
70
|
+
result |= split_gengou(this: this, other: other)
|
71
|
+
return result
|
90
72
|
end
|
91
73
|
|
92
|
-
|
74
|
+
result.push(shave_gengou(this: this, other: other))
|
75
|
+
result
|
76
|
+
end
|
93
77
|
|
94
|
-
|
95
|
-
|
96
|
-
|
78
|
+
#
|
79
|
+
# 比較により分離した元号をつなげる
|
80
|
+
#
|
81
|
+
# @param [Array<LinearGengou>] list 元号
|
82
|
+
#
|
83
|
+
# @return [Array<LinearGengou>] 同一元号がつながった元号
|
84
|
+
#
|
85
|
+
def connect(list: []) # rubocop:disable Metrics/MethodLength
|
86
|
+
result = []
|
87
|
+
list.each do |linear_gengou|
|
88
|
+
if result.size.zero?
|
89
|
+
result.push(linear_gengou)
|
90
|
+
next
|
91
|
+
end
|
92
|
+
|
93
|
+
before = result[-1]
|
94
|
+
|
95
|
+
if unconnectable?(current: linear_gengou, before: before)
|
96
|
+
result.push(linear_gengou)
|
97
|
+
next
|
98
|
+
end
|
99
|
+
|
100
|
+
result[-1] = LinearGengou.new(
|
101
|
+
start_date: before.start_date, last_date: linear_gengou.last_date,
|
102
|
+
gengou: linear_gengou.gengou
|
103
|
+
)
|
97
104
|
end
|
98
105
|
|
99
|
-
result
|
100
|
-
start_date: before.start_date, last_date: linear_gengou.last_date,
|
101
|
-
gengou: linear_gengou.gengou
|
102
|
-
)
|
106
|
+
result
|
103
107
|
end
|
104
108
|
|
105
|
-
|
106
|
-
end
|
109
|
+
private
|
107
110
|
|
108
|
-
|
109
|
-
|
111
|
+
def unconnectable?(current:, before:)
|
112
|
+
return true unless current.gengou.name == before.gengou.name
|
110
113
|
|
111
|
-
|
114
|
+
return true unless (before.last_date.clone + 1) == current.start_date
|
112
115
|
|
113
|
-
|
114
|
-
|
115
|
-
private_class_method :unconnectable?
|
116
|
+
false
|
117
|
+
end
|
116
118
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
def split_gengou(this:, other:)
|
120
|
+
[
|
121
|
+
LinearGengou.new(
|
122
|
+
start_date: this.start_date.clone, last_date: other.start_date.clone - 1,
|
123
|
+
gengou: this.gengou
|
124
|
+
),
|
125
|
+
LinearGengou.new(
|
126
|
+
start_date: other.last_date.clone + 1, last_date: this.last_date.clone,
|
127
|
+
gengou: this.gengou
|
128
|
+
)
|
129
|
+
]
|
130
|
+
end
|
131
|
+
|
132
|
+
def trim_gengou(this:, other:)
|
123
133
|
LinearGengou.new(
|
124
|
-
start_date: other.
|
134
|
+
start_date: other.start_date, last_date: other.last_date,
|
125
135
|
gengou: this.gengou
|
126
136
|
)
|
127
|
-
|
128
|
-
end
|
129
|
-
private_class_method :split_gengou
|
130
|
-
|
131
|
-
def self.trim_gengou(this:, other:)
|
132
|
-
LinearGengou.new(
|
133
|
-
start_date: other.start_date, last_date: other.last_date,
|
134
|
-
gengou: this.gengou
|
135
|
-
)
|
136
|
-
end
|
137
|
-
private_class_method :trim_gengou
|
137
|
+
end
|
138
138
|
|
139
|
-
|
140
|
-
|
141
|
-
|
139
|
+
def narrow_gengou(this:, other:)
|
140
|
+
start = this.start_date > other.start_date ? this.start_date : other.start_date
|
141
|
+
last = this.last_date < other.last_date ? this.last_date : other.last_date
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
private_class_method :narrow_gengou
|
143
|
+
LinearGengou.new(
|
144
|
+
start_date: start.clone, last_date: last.clone, gengou: this.gengou
|
145
|
+
)
|
146
|
+
end
|
148
147
|
|
149
|
-
|
150
|
-
|
151
|
-
|
148
|
+
def shave_gengou(this:, other:) # rubocop:disable Metrics/AbcSize
|
149
|
+
start = this.start_date
|
150
|
+
last = this.last_date
|
152
151
|
|
153
|
-
|
154
|
-
|
152
|
+
# 開始日が比較元号の開始日より前の範囲
|
153
|
+
last = other.start_date.clone - 1 if this.start_date < other.start_date
|
155
154
|
|
156
|
-
|
157
|
-
|
155
|
+
# 終了日が比較元号の開始日より後の範囲
|
156
|
+
start = other.last_date.clone + 1 if this.last_date > other.last_date
|
158
157
|
|
159
|
-
|
160
|
-
|
161
|
-
|
158
|
+
LinearGengou.new(
|
159
|
+
start_date: start.clone, last_date: last.clone, gengou: this.gengou
|
160
|
+
)
|
161
|
+
end
|
162
162
|
end
|
163
|
-
private_class_method :shave_gengou
|
164
163
|
end
|
165
164
|
end
|
166
165
|
end
|
@@ -72,7 +72,7 @@ module Zakuro
|
|
72
72
|
#
|
73
73
|
def get(start_date:, last_date:)
|
74
74
|
result = []
|
75
|
-
|
75
|
+
list.each do |gengou|
|
76
76
|
next if gengou.out?(start_date: start_date, last_date: last_date)
|
77
77
|
|
78
78
|
# 1日でも範囲内であれば対象とみなす
|
@@ -91,7 +91,7 @@ module Zakuro
|
|
91
91
|
#
|
92
92
|
def get_by_name(name:)
|
93
93
|
result = []
|
94
|
-
|
94
|
+
list.each do |gengou|
|
95
95
|
result.push(gengou) if gengou.name == name
|
96
96
|
end
|
97
97
|
|
@@ -110,7 +110,8 @@ module Zakuro
|
|
110
110
|
def rest(list: [])
|
111
111
|
result = []
|
112
112
|
|
113
|
-
@list
|
113
|
+
inner_list = @list
|
114
|
+
inner_list.each do |gengou|
|
114
115
|
result |= and!(rest: list, other: gengou)
|
115
116
|
end
|
116
117
|
|
@@ -123,15 +124,16 @@ module Zakuro
|
|
123
124
|
# @param [Array<LinearGengou>] list 元号
|
124
125
|
#
|
125
126
|
def insert(list: [])
|
127
|
+
inner_list = @list
|
126
128
|
surplus_result = list.clone
|
127
|
-
|
129
|
+
inner_list.each do |gengou|
|
128
130
|
surplus_result = not!(surplus: surplus_result, other: gengou)
|
129
131
|
end
|
130
132
|
|
131
133
|
surplus_result = Division.connect(list: surplus_result)
|
132
134
|
|
133
135
|
surplus_result.each do |gengou|
|
134
|
-
|
136
|
+
inner_list.push(gengou)
|
135
137
|
end
|
136
138
|
end
|
137
139
|
|
@@ -45,7 +45,7 @@ module Zakuro
|
|
45
45
|
# @return [String] 元号名
|
46
46
|
#
|
47
47
|
def name
|
48
|
-
|
48
|
+
gengou.name
|
49
49
|
end
|
50
50
|
|
51
51
|
#
|
@@ -55,7 +55,7 @@ module Zakuro
|
|
55
55
|
# @return [False] 不正なし
|
56
56
|
#
|
57
57
|
def invalid?
|
58
|
-
|
58
|
+
gengou.invalid?
|
59
59
|
end
|
60
60
|
|
61
61
|
#
|
@@ -69,13 +69,13 @@ module Zakuro
|
|
69
69
|
def include?(date: Western::Calendar.new)
|
70
70
|
return false if invalid?
|
71
71
|
|
72
|
-
return false if
|
72
|
+
return false if start_date.invalid?
|
73
73
|
|
74
|
-
return false if
|
74
|
+
return false if last_date.invalid?
|
75
75
|
|
76
|
-
return false if date <
|
76
|
+
return false if date < start_date
|
77
77
|
|
78
|
-
return false if date >
|
78
|
+
return false if date > last_date
|
79
79
|
|
80
80
|
true
|
81
81
|
end
|
@@ -90,7 +90,9 @@ module Zakuro
|
|
90
90
|
# @return [False] 範囲外あり
|
91
91
|
#
|
92
92
|
def in?(start_date:, last_date:)
|
93
|
-
|
93
|
+
inner_start_date = @start_date
|
94
|
+
inner_last_date = @last_date
|
95
|
+
inner_start_date <= start_date && last_date <= inner_last_date
|
94
96
|
end
|
95
97
|
|
96
98
|
#
|
@@ -103,11 +105,13 @@ module Zakuro
|
|
103
105
|
# @return [False] 範囲内あり
|
104
106
|
#
|
105
107
|
def out?(start_date:, last_date:)
|
108
|
+
inner_start_date = @start_date
|
109
|
+
inner_last_date = @last_date
|
106
110
|
# 範囲より前
|
107
|
-
return true if start_date <
|
111
|
+
return true if start_date < inner_start_date && last_date < inner_start_date
|
108
112
|
|
109
113
|
# 範囲より後
|
110
|
-
return true if
|
114
|
+
return true if inner_last_date < start_date && inner_last_date < last_date
|
111
115
|
|
112
116
|
false
|
113
117
|
end
|
@@ -122,7 +126,9 @@ module Zakuro
|
|
122
126
|
# @return [True] 完全超過せず
|
123
127
|
#
|
124
128
|
def covered?(start_date:, last_date:)
|
125
|
-
|
129
|
+
inner_start_date = @start_date
|
130
|
+
inner_last_date = @last_date
|
131
|
+
start_date < inner_start_date && inner_last_date < last_date
|
126
132
|
end
|
127
133
|
|
128
134
|
#
|
@@ -148,7 +154,7 @@ module Zakuro
|
|
148
154
|
def change_start_date?
|
149
155
|
return false if invalid?
|
150
156
|
|
151
|
-
|
157
|
+
start_date != native_start_date
|
152
158
|
end
|
153
159
|
|
154
160
|
#
|
@@ -160,7 +166,7 @@ module Zakuro
|
|
160
166
|
def change_last_date?
|
161
167
|
return false if invalid?
|
162
168
|
|
163
|
-
|
169
|
+
last_date != native_last_date
|
164
170
|
end
|
165
171
|
|
166
172
|
#
|
@@ -169,7 +175,7 @@ module Zakuro
|
|
169
175
|
# @return [Western::Calendar]設定された元号の開始日
|
170
176
|
#
|
171
177
|
def native_start_date
|
172
|
-
|
178
|
+
gengou.both_start_date.western
|
173
179
|
end
|
174
180
|
|
175
181
|
#
|
@@ -178,7 +184,7 @@ module Zakuro
|
|
178
184
|
# @return [Western::Calendar] 設定された元号の終了日
|
179
185
|
#
|
180
186
|
def native_last_date
|
181
|
-
|
187
|
+
gengou.last_date
|
182
188
|
end
|
183
189
|
end
|
184
190
|
end
|
@@ -23,31 +23,33 @@ module Zakuro
|
|
23
23
|
# @return [Aligner] 整列結果
|
24
24
|
SUMMARY = Aligner.new(resources: Resource::LIST)
|
25
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
|
-
|
26
|
+
class << self
|
27
|
+
#
|
28
|
+
# 指定した範囲内の元号を取得する
|
29
|
+
#
|
30
|
+
# @param [Integer] line 行
|
31
|
+
# @param [Western::Calendar] start_date 開始日
|
32
|
+
# @param [Western::Calendar] last_date 終了日
|
33
|
+
#
|
34
|
+
# @return [Array<LinearGengou>] 元号
|
35
|
+
#
|
36
|
+
def get(line: FIRST_LINE,
|
37
|
+
start_date: Western::Calendar.new, last_date: Western::Calendar.new)
|
38
|
+
|
39
|
+
SUMMARY.get(line: line, start_date: start_date, last_date: last_date)
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# 指定した範囲内の元号を取得する(元号名)
|
44
|
+
#
|
45
|
+
# @param [Integer] line 行
|
46
|
+
# @param [String] name 元号名
|
47
|
+
#
|
48
|
+
# @return [Array<LinearGengou>] 元号
|
49
|
+
#
|
50
|
+
def get_by_name(line: FIRST_LINE, name:)
|
51
|
+
SUMMARY.get_by_name(line: line, name: name)
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|