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,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../range/named_operation_range'
|
4
|
+
|
5
|
+
require_relative '../../range/named_full_range'
|
6
|
+
|
7
|
+
require_relative '../western/specifier/multiple_day'
|
8
|
+
|
9
|
+
require_relative '../internal/operation'
|
10
|
+
|
11
|
+
require_relative './specifier/single_day'
|
12
|
+
|
13
|
+
# :nodoc:
|
14
|
+
module Zakuro
|
15
|
+
# :nodoc:
|
16
|
+
module Calculation
|
17
|
+
# :nodoc:
|
18
|
+
module Summary
|
19
|
+
# :nodoc:
|
20
|
+
module Japan
|
21
|
+
#
|
22
|
+
# Range 期間
|
23
|
+
#
|
24
|
+
module Range
|
25
|
+
#
|
26
|
+
# 生成する
|
27
|
+
#
|
28
|
+
# @param [Context] context 暦コンテキスト
|
29
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
30
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
31
|
+
#
|
32
|
+
# @return [Result::Range] 期間検索結果(和暦日)
|
33
|
+
#
|
34
|
+
def self.get(context:, start_date: Japan::Calendar.new,
|
35
|
+
last_date: Japan::Calendar.new)
|
36
|
+
years = get_full_range_years(
|
37
|
+
context: context, start_date: start_date, last_date: last_date
|
38
|
+
)
|
39
|
+
operated_years = get_operation_range_years(
|
40
|
+
context: context, years: years, start_date: start_date, last_date: last_date
|
41
|
+
)
|
42
|
+
|
43
|
+
japan_start_date = Specifier::SingleDay.get(years: operated_years, date: start_date)
|
44
|
+
japan_last_date = Specifier::SingleDay.get(years: operated_years, date: last_date)
|
45
|
+
|
46
|
+
list = create_list(
|
47
|
+
operated_years: operated_years, years: years,
|
48
|
+
start_date: japan_start_date, last_date: japan_last_date
|
49
|
+
)
|
50
|
+
|
51
|
+
Result::Range.new(list: list)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# <Description>
|
56
|
+
#
|
57
|
+
# @param [Array<Base::OperatedYear>] operated_years 運用結果範囲
|
58
|
+
# @param [Array<Base::Year>] years 完全範囲
|
59
|
+
# @param [Result::Data::SingleDay] start_date 和暦開始日
|
60
|
+
# @param [Result::Data::SingleDay] last_date 和暦終了日
|
61
|
+
#
|
62
|
+
# @return [Array<Result::Single>] 結果リスト
|
63
|
+
#
|
64
|
+
def self.create_list(operated_years: [], years: [],
|
65
|
+
start_date:, last_date:)
|
66
|
+
western_start_date = start_date.day.western_date
|
67
|
+
western_last_date = last_date.day.western_date
|
68
|
+
|
69
|
+
operated_dates = Western::Specifier::MultipleDay.get(
|
70
|
+
years: operated_years, start_date: western_start_date, last_date: western_last_date
|
71
|
+
)
|
72
|
+
|
73
|
+
dates = Western::Specifier::MultipleDay.get(
|
74
|
+
years: years, start_date: western_start_date, last_date: western_last_date
|
75
|
+
)
|
76
|
+
|
77
|
+
create_result_list(dates: dates, operated_dates: operated_dates)
|
78
|
+
end
|
79
|
+
private_class_method :create_list
|
80
|
+
|
81
|
+
#
|
82
|
+
# 完全範囲を取得する
|
83
|
+
#
|
84
|
+
# @param [Context] context 暦コンテキスト
|
85
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
86
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
87
|
+
#
|
88
|
+
# @return [Array<Base::Year>] 完全範囲
|
89
|
+
#
|
90
|
+
def self.get_full_range_years(context:, start_date: Japan::Calendar.new,
|
91
|
+
last_date: Japan::Calendar.new)
|
92
|
+
full_range = Calculation::Range::NamedFullRange.new(
|
93
|
+
context: context, start_name: start_date.gengou, last_name: last_date.gengou
|
94
|
+
)
|
95
|
+
full_range.get
|
96
|
+
end
|
97
|
+
private_class_method :get_full_range_years
|
98
|
+
|
99
|
+
#
|
100
|
+
# 運用結果範囲を取得する
|
101
|
+
#
|
102
|
+
# @param [Context] context 暦コンテキスト
|
103
|
+
# @param [Array<Base::Year>] years 完全範囲
|
104
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
105
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
106
|
+
#
|
107
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
108
|
+
#
|
109
|
+
def self.get_operation_range_years(context:, years:, start_date: Japan::Calendar.new,
|
110
|
+
last_date: Japan::Calendar.new)
|
111
|
+
operation_range = Calculation::Range::NamedOperationRange.new(
|
112
|
+
context: context, years: years,
|
113
|
+
start_name: start_date.gengou, last_name: last_date.gengou
|
114
|
+
)
|
115
|
+
operation_range.get
|
116
|
+
end
|
117
|
+
private_class_method :get_operation_range_years
|
118
|
+
|
119
|
+
#
|
120
|
+
# 結果リストを生成する
|
121
|
+
#
|
122
|
+
# @param [Array<Result::Data::SingleDay>] dates 検索結果(計算値)
|
123
|
+
# @param [Array<Result::Data::SingleDay>] operated_dates 検索結果(運用値)
|
124
|
+
#
|
125
|
+
# @return [Array<Result::Single>] 結果リスト
|
126
|
+
#
|
127
|
+
def self.create_result_list(dates:, operated_dates:)
|
128
|
+
result = []
|
129
|
+
|
130
|
+
return result if dates.size != operated_dates.size
|
131
|
+
|
132
|
+
(0..(dates.size - 1)).each do |index|
|
133
|
+
data = operated_dates[index]
|
134
|
+
|
135
|
+
date = dates[index]
|
136
|
+
operation = Operation.create(calc_date: date)
|
137
|
+
|
138
|
+
result.push(
|
139
|
+
Result::Single.new(
|
140
|
+
data: data,
|
141
|
+
operation: operation
|
142
|
+
)
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
result
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../range/named_operation_range'
|
4
|
+
|
5
|
+
require_relative '../../range/named_full_range'
|
6
|
+
|
7
|
+
require_relative '../western/specifier/single_day'
|
8
|
+
|
9
|
+
require_relative '../internal/operation'
|
10
|
+
|
11
|
+
require_relative './specifier/single_day'
|
12
|
+
|
13
|
+
# :nodoc:
|
14
|
+
module Zakuro
|
15
|
+
# :nodoc:
|
16
|
+
module Calculation
|
17
|
+
# :nodoc:
|
18
|
+
module Summary
|
19
|
+
# :nodoc:
|
20
|
+
module Japan
|
21
|
+
#
|
22
|
+
# Single 一日
|
23
|
+
#
|
24
|
+
module Single
|
25
|
+
#
|
26
|
+
# 生成する
|
27
|
+
#
|
28
|
+
# @param [Context] context 暦コンテキスト
|
29
|
+
# @param [Japan::Calendar] date 和暦日
|
30
|
+
#
|
31
|
+
# @return [Result::Single] 一日検索結果(和暦日)
|
32
|
+
#
|
33
|
+
def self.get(context:, date: Japan::Calendar.new)
|
34
|
+
years = get_full_range_years(context: context, date: date)
|
35
|
+
|
36
|
+
data = get_data(context: context, years: years, date: date)
|
37
|
+
|
38
|
+
western_date = data.day.western_date
|
39
|
+
operation = get_operation(years: years, date: western_date)
|
40
|
+
|
41
|
+
Result::Single.new(
|
42
|
+
data: data,
|
43
|
+
operation: operation
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# 完全範囲を取得する
|
49
|
+
#
|
50
|
+
# @param [Context] context 暦コンテキスト
|
51
|
+
# @param [Japan::Calendar] date 和暦日
|
52
|
+
#
|
53
|
+
# @return [Array<Base::Year>] 完全範囲
|
54
|
+
#
|
55
|
+
def self.get_full_range_years(context:, date: Japan::Calendar.new)
|
56
|
+
full_range = Calculation::Range::NamedFullRange.new(
|
57
|
+
context: context, start_name: date.gengou
|
58
|
+
)
|
59
|
+
full_range.get
|
60
|
+
end
|
61
|
+
private_class_method :get_full_range_years
|
62
|
+
|
63
|
+
#
|
64
|
+
# 1日を取得する
|
65
|
+
#
|
66
|
+
# @param [Context] context 暦コンテキスト
|
67
|
+
# @param [Array<Base::Year>] years 完全範囲
|
68
|
+
# @param [Japan::Calendar] date 和暦日
|
69
|
+
#
|
70
|
+
# @return [Data::SingleDay] 1日
|
71
|
+
#
|
72
|
+
def self.get_data(context:, years:, date: Japan::Calendar.new)
|
73
|
+
operated_years = get_operation_range_years(context: context, years: years, date: date)
|
74
|
+
|
75
|
+
Specifier::SingleDay.get(
|
76
|
+
years: operated_years, date: date
|
77
|
+
)
|
78
|
+
end
|
79
|
+
private_class_method :get_data
|
80
|
+
|
81
|
+
#
|
82
|
+
# 運用結果範囲を取得する
|
83
|
+
#
|
84
|
+
# @param [Context] context 暦コンテキスト
|
85
|
+
# @param [Array<Base::Year>] years 完全範囲
|
86
|
+
# @param [Japan::Calendar] date 和暦日
|
87
|
+
#
|
88
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
89
|
+
#
|
90
|
+
def self.get_operation_range_years(context:, years:, date: Japan::Calendar.new)
|
91
|
+
operation_range = Calculation::Range::NamedOperationRange.new(
|
92
|
+
context: context, start_name: date.gengou, years: years
|
93
|
+
)
|
94
|
+
operation_range.get
|
95
|
+
end
|
96
|
+
private_class_method :get_operation_range_years
|
97
|
+
|
98
|
+
#
|
99
|
+
# 完全範囲を取得する
|
100
|
+
#
|
101
|
+
# @param [Context] context 暦コンテキスト
|
102
|
+
# @param [Western::Calendar] date 和暦日
|
103
|
+
#
|
104
|
+
# @return [Array<Base::Year>] 完全範囲
|
105
|
+
#
|
106
|
+
def self.get_operation(years:, date: Western::Calendar.new)
|
107
|
+
calc_date = Western::Specifier::SingleDay.get(
|
108
|
+
years: years, date: date
|
109
|
+
)
|
110
|
+
|
111
|
+
Operation.create(calc_date: calc_date)
|
112
|
+
end
|
113
|
+
private_class_method :get_operation
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../era/japan/calendar'
|
4
|
+
require_relative '../../../../era/western/calendar'
|
5
|
+
require_relative '../../../../output/response'
|
6
|
+
require_relative '../../../../output/logger'
|
7
|
+
|
8
|
+
require_relative '../../../base/year'
|
9
|
+
|
10
|
+
# :nodoc:
|
11
|
+
module Zakuro
|
12
|
+
# :nodoc:
|
13
|
+
module Calculation
|
14
|
+
# :nodoc:
|
15
|
+
module Summary
|
16
|
+
# :nodoc:
|
17
|
+
module Japan
|
18
|
+
# :nodoc:
|
19
|
+
module Specifier
|
20
|
+
#
|
21
|
+
# SingleDay 一日検索
|
22
|
+
#
|
23
|
+
module SingleDay
|
24
|
+
# @return [Output::Logger] ロガー
|
25
|
+
LOGGER = Output::Logger.new(location: 'specifier')
|
26
|
+
|
27
|
+
#
|
28
|
+
# 取得する
|
29
|
+
#
|
30
|
+
# @param [Array<Year>] yeas 範囲
|
31
|
+
# @param [Japan::Calendar] date 和暦日
|
32
|
+
#
|
33
|
+
# @return [Result::Data::SingleDay] 和暦日
|
34
|
+
#
|
35
|
+
def self.get(years: [], date: Japan::Calendar.new)
|
36
|
+
year, month = specify(years: years, date: date)
|
37
|
+
first_date = month.western_date.clone
|
38
|
+
days = date.day - 1
|
39
|
+
western_date = first_date + days
|
40
|
+
|
41
|
+
Output::Response::SingleDay.save_single_day(
|
42
|
+
param: Output::Response::SingleDay::Param.new(
|
43
|
+
year: year, month: month,
|
44
|
+
date: western_date, days: days
|
45
|
+
)
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# 年を特定する
|
51
|
+
#
|
52
|
+
# @param [Array<Year>] years 範囲
|
53
|
+
# @param [Japan::Calendar] date 和暦日
|
54
|
+
#
|
55
|
+
# @return [Base::Year] 対象年
|
56
|
+
# @return [Monthly::Month] 対象月
|
57
|
+
#
|
58
|
+
def self.specify(years:, date:)
|
59
|
+
years.each do |year|
|
60
|
+
month = specify_month(year: year, date: date)
|
61
|
+
return year, month unless month.invalid?
|
62
|
+
end
|
63
|
+
|
64
|
+
raise ArgumentError, "invalid year range. date: #{date.format}"
|
65
|
+
end
|
66
|
+
private_class_method :specify
|
67
|
+
|
68
|
+
#
|
69
|
+
# 月を特定する
|
70
|
+
#
|
71
|
+
# @param [Base::Year] year 年
|
72
|
+
# @param [Japan::Calendar] date 和暦日
|
73
|
+
#
|
74
|
+
# @return [Monthly::Month] 対象月
|
75
|
+
#
|
76
|
+
def self.specify_month(year:, date:)
|
77
|
+
months = year.months
|
78
|
+
|
79
|
+
months.each do |month|
|
80
|
+
return month if month.include_by_japan_date?(date: date)
|
81
|
+
end
|
82
|
+
|
83
|
+
Monthly::Month.new
|
84
|
+
end
|
85
|
+
private_class_method :specify_month
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../range/dated_operation_range'
|
4
|
+
|
5
|
+
require_relative '../../range/dated_full_range'
|
6
|
+
|
7
|
+
require_relative './specifier/multiple_day'
|
8
|
+
|
9
|
+
require_relative '../internal/operation'
|
10
|
+
|
11
|
+
# :nodoc:
|
12
|
+
module Zakuro
|
13
|
+
# :nodoc:
|
14
|
+
module Calculation
|
15
|
+
# :nodoc:
|
16
|
+
module Summary
|
17
|
+
# :nodoc:
|
18
|
+
module Western
|
19
|
+
#
|
20
|
+
# Range 期間
|
21
|
+
#
|
22
|
+
module Range
|
23
|
+
#
|
24
|
+
# 生成する
|
25
|
+
#
|
26
|
+
# @param [Context] context 暦コンテキスト
|
27
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
28
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
29
|
+
#
|
30
|
+
# @return [Result::Range] 期間検索結果(和暦日)
|
31
|
+
#
|
32
|
+
def self.get(context:, start_date: Western::Calendar.new,
|
33
|
+
last_date: Western::Calendar.new)
|
34
|
+
years = get_full_range_years(
|
35
|
+
context: context, start_date: start_date, last_date: last_date
|
36
|
+
)
|
37
|
+
operated_years = get_operation_range_years(
|
38
|
+
context: context, years: years, start_date: start_date, last_date: last_date
|
39
|
+
)
|
40
|
+
|
41
|
+
dates = Specifier::MultipleDay.get(
|
42
|
+
years: years, start_date: start_date, last_date: last_date
|
43
|
+
)
|
44
|
+
|
45
|
+
operated_dates = Specifier::MultipleDay.get(
|
46
|
+
years: operated_years, start_date: start_date, last_date: last_date
|
47
|
+
)
|
48
|
+
|
49
|
+
list = create_result_list(dates: dates, operated_dates: operated_dates)
|
50
|
+
|
51
|
+
Result::Range.new(list: list)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# 完全範囲を取得する
|
56
|
+
#
|
57
|
+
# @param [Context] context 暦コンテキスト
|
58
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
59
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
60
|
+
#
|
61
|
+
# @return [Array<Base::Year>] 完全範囲
|
62
|
+
#
|
63
|
+
def self.get_full_range_years(context:, start_date: Western::Calendar.new,
|
64
|
+
last_date: Western::Calendar.new)
|
65
|
+
full_range = Calculation::Range::DatedFullRange.new(
|
66
|
+
context: context, start_date: start_date, last_date: last_date
|
67
|
+
)
|
68
|
+
full_range.get
|
69
|
+
end
|
70
|
+
private_class_method :get_full_range_years
|
71
|
+
|
72
|
+
#
|
73
|
+
# 運用結果範囲を取得する
|
74
|
+
#
|
75
|
+
# @param [Context] context 暦コンテキスト
|
76
|
+
# @param [Array<Base::Year>] years 完全範囲
|
77
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
78
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
79
|
+
#
|
80
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
81
|
+
#
|
82
|
+
def self.get_operation_range_years(context:, years:, start_date: Western::Calendar.new,
|
83
|
+
last_date: Western::Calendar.new)
|
84
|
+
operation_range = Calculation::Range::DatedOperationRange.new(
|
85
|
+
context: context, start_date: start_date, last_date: last_date, years: years
|
86
|
+
)
|
87
|
+
operation_range.get
|
88
|
+
end
|
89
|
+
private_class_method :get_operation_range_years
|
90
|
+
|
91
|
+
#
|
92
|
+
# 結果リストを生成する
|
93
|
+
#
|
94
|
+
# @param [Array<Result::Data::SingleDay>] dates 検索結果(計算値)
|
95
|
+
# @param [Array<Result::Data::SingleDay>] operated_dates 検索結果(運用値)
|
96
|
+
#
|
97
|
+
# @return [Array<Result::Single>] 結果リスト
|
98
|
+
#
|
99
|
+
def self.create_result_list(dates:, operated_dates:)
|
100
|
+
result = []
|
101
|
+
|
102
|
+
return result if dates.size != operated_dates.size
|
103
|
+
|
104
|
+
(0..(dates.size - 1)).each do |index|
|
105
|
+
data = operated_dates[index]
|
106
|
+
|
107
|
+
date = dates[index]
|
108
|
+
operation = Operation.create(calc_date: date)
|
109
|
+
|
110
|
+
result.push(
|
111
|
+
Result::Single.new(
|
112
|
+
data: data,
|
113
|
+
operation: operation
|
114
|
+
)
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
result
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../range/dated_operation_range'
|
4
|
+
|
5
|
+
require_relative '../../range/dated_full_range'
|
6
|
+
|
7
|
+
require_relative './specifier/single_day'
|
8
|
+
|
9
|
+
require_relative '../internal/operation'
|
10
|
+
|
11
|
+
# :nodoc:
|
12
|
+
module Zakuro
|
13
|
+
# :nodoc:
|
14
|
+
module Calculation
|
15
|
+
# :nodoc:
|
16
|
+
module Summary
|
17
|
+
# :nodoc:
|
18
|
+
module Western
|
19
|
+
#
|
20
|
+
# Single 一日
|
21
|
+
#
|
22
|
+
module Single
|
23
|
+
#
|
24
|
+
# 生成する
|
25
|
+
#
|
26
|
+
# @param [Context] context 暦コンテキスト
|
27
|
+
# @param [Western::Calendar] date 西暦日
|
28
|
+
#
|
29
|
+
# @return [Result::Single] 一日検索結果(和暦日)
|
30
|
+
#
|
31
|
+
def self.get(context:, date: Western::Calendar.new)
|
32
|
+
years = get_full_range_years(context: context, date: date)
|
33
|
+
|
34
|
+
data = get_data(context: context, years: years, date: date)
|
35
|
+
|
36
|
+
operation = get_operation(years: years, date: date)
|
37
|
+
|
38
|
+
Result::Single.new(
|
39
|
+
data: data,
|
40
|
+
operation: operation
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# 完全範囲を取得する
|
46
|
+
#
|
47
|
+
# @param [Context] context 暦コンテキスト
|
48
|
+
# @param [Western::Calendar] date 西暦日
|
49
|
+
#
|
50
|
+
# @return [Array<Base::Year>] 完全範囲
|
51
|
+
#
|
52
|
+
def self.get_full_range_years(context:, date: Western::Calendar.new)
|
53
|
+
full_range = Calculation::Range::DatedFullRange.new(context: context, start_date: date)
|
54
|
+
full_range.get
|
55
|
+
end
|
56
|
+
private_class_method :get_full_range_years
|
57
|
+
|
58
|
+
#
|
59
|
+
# 運用結果範囲を取得する
|
60
|
+
#
|
61
|
+
# @param [Context] context 暦コンテキスト
|
62
|
+
# @param [Array<Base::Year>] years 完全範囲
|
63
|
+
# @param [Western::Calendar] date 西暦日
|
64
|
+
#
|
65
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
66
|
+
#
|
67
|
+
def self.get_operation_range_years(context:, years:, date: Western::Calendar.new)
|
68
|
+
operation_range = Calculation::Range::DatedOperationRange.new(
|
69
|
+
context: context, start_date: date, years: years
|
70
|
+
)
|
71
|
+
operation_range.get
|
72
|
+
end
|
73
|
+
private_class_method :get_operation_range_years
|
74
|
+
|
75
|
+
#
|
76
|
+
# 1日を取得する
|
77
|
+
#
|
78
|
+
# @param [Context] context 暦コンテキスト
|
79
|
+
# @param [Array<Base::Year>] years 完全範囲
|
80
|
+
# @param [Western::Calendar] date 西暦日
|
81
|
+
#
|
82
|
+
# @return [Data::SingleDay] 1日
|
83
|
+
#
|
84
|
+
def self.get_data(context:, years:, date: Western::Calendar.new)
|
85
|
+
operated_years = get_operation_range_years(context: context, years: years, date: date)
|
86
|
+
|
87
|
+
Specifier::SingleDay.get(
|
88
|
+
years: operated_years, date: date
|
89
|
+
)
|
90
|
+
end
|
91
|
+
private_class_method :get_data
|
92
|
+
|
93
|
+
#
|
94
|
+
# 完全範囲を取得する
|
95
|
+
#
|
96
|
+
# @param [Context] context 暦コンテキスト
|
97
|
+
# @param [Western::Calendar] date 西暦日
|
98
|
+
#
|
99
|
+
# @return [Array<Base::Year>] 完全範囲
|
100
|
+
#
|
101
|
+
def self.get_operation(years:, date: Western::Calendar.new)
|
102
|
+
calc_date = Specifier::SingleDay.get(
|
103
|
+
years: years, date: date
|
104
|
+
)
|
105
|
+
|
106
|
+
Operation.create(calc_date: calc_date)
|
107
|
+
end
|
108
|
+
private_class_method :get_operation
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|