zakuro 0.7.2 → 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/README.md +3 -3
- data/VERSION +1 -1
- 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 +23 -21
- data/lib/zakuro/calculation/base/year.rb +3 -3
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +50 -44
- 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 +39 -37
- data/lib/zakuro/calculation/monthly/month.rb +15 -15
- data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
- data/lib/zakuro/calculation/monthly/operated_month.rb +36 -85
- data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
- data/lib/zakuro/calculation/range/abstract_full_range.rb +34 -21
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +109 -107
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- 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 +5 -5
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
- data/lib/zakuro/calculation/summary/internal/day.rb +21 -19
- data/lib/zakuro/calculation/summary/internal/month.rb +25 -12
- data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
- data/lib/zakuro/calculation/summary/internal/option.rb +66 -50
- data/lib/zakuro/calculation/summary/japan/range.rb +145 -124
- data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +54 -52
- 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 -124
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +60 -58
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/condition.rb +121 -111
- data/lib/zakuro/context/context.rb +1 -1
- data/lib/zakuro/context/option.rb +31 -29
- data/lib/zakuro/context/version_class_resolver.rb +26 -24
- data/lib/zakuro/era/japan/calendar.rb +35 -33
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +4 -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 -36
- data/lib/zakuro/era/japan/gengou/resource/type.rb +39 -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 +102 -90
- data/lib/zakuro/exception/case/preset.rb +2 -2
- data/lib/zakuro/exception/exception.rb +15 -13
- data/lib/zakuro/exception/zakuro_error.rb +1 -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 +1 -1
- data/lib/zakuro/gateway/single.rb +13 -2
- data/lib/zakuro/merchant.rb +1 -1
- data/lib/zakuro/operation/month/parser.rb +252 -251
- 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/output/response.rb +112 -113
- 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 +66 -64
- data/lib/zakuro/tools/typeconv.rb +17 -15
- data/lib/zakuro/tools/typeof.rb +15 -13
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
- data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -39
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -49
- 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 +2 -2
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
- 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/monthly/lunar_phase.rb +9 -9
- data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -39
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -49
- 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/monthly/lunar_phase.rb +10 -10
- data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -38
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -36
- 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 +12 -9
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
- data/lib/zakuro/result/operation/bundle.rb +0 -44
- data/lib/zakuro/result/operation/month/bundle.rb +0 -36
@@ -20,102 +20,105 @@ module Zakuro
|
|
20
20
|
# Range 期間
|
21
21
|
#
|
22
22
|
module Range
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
dates = Specifier::MultipleDay.get(
|
42
|
-
context: context, years: years, start_date: start_date, last_date: last_date
|
43
|
-
)
|
44
|
-
|
45
|
-
operated_dates = Specifier::MultipleDay.get(
|
46
|
-
context: context, 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
|
23
|
+
class << self
|
24
|
+
#
|
25
|
+
# 生成する
|
26
|
+
#
|
27
|
+
# @param [Context::Context] context 暦コンテキスト
|
28
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
29
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
30
|
+
#
|
31
|
+
# @return [Result::Range] 期間検索結果(和暦日)
|
32
|
+
#
|
33
|
+
def get(context:, start_date: Western::Calendar.new,
|
34
|
+
last_date: Western::Calendar.new)
|
35
|
+
years = get_full_range_years(
|
36
|
+
context: context, start_date: start_date, last_date: last_date
|
37
|
+
)
|
38
|
+
operated_years = get_operation_range_years(
|
39
|
+
context: context, years: years, start_date: start_date, last_date: last_date
|
40
|
+
)
|
53
41
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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] 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
|
-
)
|
42
|
+
dates = Specifier::MultipleDay.get(
|
43
|
+
context: context, years: years, start_date: start_date, last_date: last_date
|
44
|
+
)
|
45
|
+
|
46
|
+
operated_dates = Specifier::MultipleDay.get(
|
47
|
+
context: context, years: operated_years,
|
48
|
+
start_date: start_date, last_date: last_date
|
115
49
|
)
|
50
|
+
|
51
|
+
list = create_result_list(dates: dates, operated_dates: operated_dates)
|
52
|
+
|
53
|
+
Result::Range.new(list: list)
|
116
54
|
end
|
117
55
|
|
118
|
-
|
56
|
+
private
|
57
|
+
|
58
|
+
#
|
59
|
+
# 完全範囲を取得する
|
60
|
+
#
|
61
|
+
# @param [Context::Context] context 暦コンテキスト
|
62
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
63
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
64
|
+
#
|
65
|
+
# @return [Array<Base::Year>] 完全範囲
|
66
|
+
#
|
67
|
+
def get_full_range_years(context:, start_date: Western::Calendar.new,
|
68
|
+
last_date: Western::Calendar.new)
|
69
|
+
full_range = Calculation::Range::DatedFullRange.new(
|
70
|
+
context: context, start_date: start_date, last_date: last_date
|
71
|
+
)
|
72
|
+
full_range.get
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# 運用結果範囲を取得する
|
77
|
+
#
|
78
|
+
# @param [Context::Context] context 暦コンテキスト
|
79
|
+
# @param [Array<Base::Year>] years 完全範囲
|
80
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
81
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
82
|
+
#
|
83
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
84
|
+
#
|
85
|
+
def get_operation_range_years(context:, years:, start_date: Western::Calendar.new,
|
86
|
+
last_date: Western::Calendar.new)
|
87
|
+
operation_range = Calculation::Range::DatedOperationRange.new(
|
88
|
+
context: context, start_date: start_date, last_date: last_date, years: years
|
89
|
+
)
|
90
|
+
operation_range.get
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# 結果リストを生成する
|
95
|
+
#
|
96
|
+
# @param [Array<Result::Data::SingleDay>] dates 検索結果(計算値)
|
97
|
+
# @param [Array<Result::Data::SingleDay>] operated_dates 検索結果(運用値)
|
98
|
+
#
|
99
|
+
# @return [Array<Result::Single>] 結果リスト
|
100
|
+
#
|
101
|
+
def create_result_list(dates:, operated_dates:)
|
102
|
+
result = []
|
103
|
+
|
104
|
+
return result if dates.size != operated_dates.size
|
105
|
+
|
106
|
+
(0..(dates.size - 1)).each do |index|
|
107
|
+
data = operated_dates[index]
|
108
|
+
|
109
|
+
date = dates[index]
|
110
|
+
operation = Operation.create(calc_date: date)
|
111
|
+
|
112
|
+
result.push(
|
113
|
+
Result::Single.new(
|
114
|
+
data: data,
|
115
|
+
operation: operation
|
116
|
+
)
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
result
|
121
|
+
end
|
119
122
|
end
|
120
123
|
end
|
121
124
|
end
|
@@ -20,92 +20,94 @@ module Zakuro
|
|
20
20
|
# Single 一日
|
21
21
|
#
|
22
22
|
module Single
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
class << self
|
24
|
+
#
|
25
|
+
# 生成する
|
26
|
+
#
|
27
|
+
# @param [Context::Context] context 暦コンテキスト
|
28
|
+
# @param [Western::Calendar] date 西暦日
|
29
|
+
#
|
30
|
+
# @return [Result::Single] 一日検索結果(和暦日)
|
31
|
+
#
|
32
|
+
def get(context:, date: Western::Calendar.new)
|
33
|
+
years = get_full_range_years(context: context, date: date)
|
33
34
|
|
34
|
-
|
35
|
+
data = get_data(context: context, years: years, date: date)
|
35
36
|
|
36
|
-
|
37
|
+
operation = get_operation(years: years, date: date)
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
Result::Single.new(
|
40
|
+
data: data,
|
41
|
+
operation: operation
|
42
|
+
)
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
# 完全範囲を取得する
|
46
|
-
#
|
47
|
-
# @param [Context::Context] context 暦コンテキスト
|
48
|
-
# @param [Western::Calendar] date 西暦日
|
49
|
-
#
|
50
|
-
# @return [Array<Calculation::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
|
45
|
+
private
|
57
46
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
private_class_method :get_operation_range_years
|
47
|
+
#
|
48
|
+
# 完全範囲を取得する
|
49
|
+
#
|
50
|
+
# @param [Context::Context] context 暦コンテキスト
|
51
|
+
# @param [Western::Calendar] date 西暦日
|
52
|
+
#
|
53
|
+
# @return [Array<Calculation::Base::Year>] 完全範囲
|
54
|
+
#
|
55
|
+
def get_full_range_years(context:, date: Western::Calendar.new)
|
56
|
+
full_range = Calculation::Range::DatedFullRange.new(
|
57
|
+
context: context, start_date: date
|
58
|
+
)
|
59
|
+
full_range.get
|
60
|
+
end
|
74
61
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
62
|
+
#
|
63
|
+
# 運用結果範囲を取得する
|
64
|
+
#
|
65
|
+
# @param [Context::Context] context 暦コンテキスト
|
66
|
+
# @param [Array<Calculation::Base::Year>] years 完全範囲
|
67
|
+
# @param [Western::Calendar] date 西暦日
|
68
|
+
#
|
69
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
70
|
+
#
|
71
|
+
def get_operation_range_years(context:, years:, date: Western::Calendar.new)
|
72
|
+
operation_range = Calculation::Range::DatedOperationRange.new(
|
73
|
+
context: context, start_date: date, years: years
|
74
|
+
)
|
75
|
+
operation_range.get
|
76
|
+
end
|
86
77
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
78
|
+
#
|
79
|
+
# 1日を取得する
|
80
|
+
#
|
81
|
+
# @param [Context::Context] context 暦コンテキスト
|
82
|
+
# @param [Array<Calculation::Base::Year>] years 完全範囲
|
83
|
+
# @param [Western::Calendar] date 西暦日
|
84
|
+
#
|
85
|
+
# @return [Data::SingleDay] 1日
|
86
|
+
#
|
87
|
+
def get_data(context:, years:, date: Western::Calendar.new)
|
88
|
+
operated_years = get_operation_range_years(context: context, years: years, date: date)
|
89
|
+
|
90
|
+
Specifier::SingleDay.get(
|
91
|
+
years: operated_years, date: date
|
92
|
+
)
|
93
|
+
end
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
95
|
+
#
|
96
|
+
# 完全範囲を取得する
|
97
|
+
#
|
98
|
+
# @param [Array<Calculation::Base::Year>] years 完全範囲
|
99
|
+
# @param [Western::Calendar] date 西暦日
|
100
|
+
#
|
101
|
+
# @return [Array<Calculation::Base::Year>] 完全範囲
|
102
|
+
#
|
103
|
+
def get_operation(years:, date: Western::Calendar.new)
|
104
|
+
calc_date = Specifier::SingleDay.get(
|
105
|
+
years: years, date: date
|
106
|
+
)
|
105
107
|
|
106
|
-
|
108
|
+
Operation.create(calc_date: calc_date)
|
109
|
+
end
|
107
110
|
end
|
108
|
-
private_class_method :get_operation
|
109
111
|
end
|
110
112
|
end
|
111
113
|
end
|
@@ -25,147 +25,146 @@ module Zakuro
|
|
25
25
|
# @return [Output::Logger] ロガー
|
26
26
|
LOGGER = Output::Logger.new(location: 'specifier')
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
result = []
|
45
|
-
months.each do |month|
|
46
|
-
result |= month.get
|
47
|
-
end
|
28
|
+
class << self
|
29
|
+
#
|
30
|
+
# 取得する
|
31
|
+
#
|
32
|
+
# @param [Context::Context] context 暦コンテキスト
|
33
|
+
# @param [Array<Calculation::Base::Year>] years 範囲
|
34
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
35
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
36
|
+
#
|
37
|
+
# @return [Array<Result::Data::SingleDay>] 期間検索結果(和暦日)
|
38
|
+
#
|
39
|
+
def get(context:, years: [], start_date: Western::Calendar.new,
|
40
|
+
last_date: Western::Calendar.new)
|
41
|
+
months = specify(
|
42
|
+
context: context, years: years, start_date: start_date, last_date: last_date
|
43
|
+
)
|
48
44
|
|
49
|
-
|
50
|
-
|
45
|
+
result = []
|
46
|
+
months.each do |month|
|
47
|
+
result |= month.get
|
48
|
+
end
|
51
49
|
|
52
|
-
|
53
|
-
# 年を特定する
|
54
|
-
#
|
55
|
-
# @param [Context::Context] context 暦コンテキスト
|
56
|
-
# @param [Array<Calculation::Base::Year>] years 範囲
|
57
|
-
# @param [Western::Calendar] start_date 西暦開始日
|
58
|
-
# @param [Western::Calendar] last_date 西暦終了日
|
59
|
-
#
|
60
|
-
# @return [Array<Month>] 特定月
|
61
|
-
#
|
62
|
-
def self.specify(context:, years: [], start_date: Western::Calendar.new,
|
63
|
-
last_date: Western::Calendar.new)
|
64
|
-
result = []
|
65
|
-
years.each do |year|
|
66
|
-
result |= specify_month(
|
67
|
-
context: context, year: year, start_date: start_date, last_date: last_date
|
68
|
-
)
|
50
|
+
result
|
69
51
|
end
|
70
52
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
53
|
+
private
|
54
|
+
|
55
|
+
#
|
56
|
+
# 年を特定する
|
57
|
+
#
|
58
|
+
# @param [Context::Context] context 暦コンテキスト
|
59
|
+
# @param [Array<Calculation::Base::Year>] years 範囲
|
60
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
61
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
62
|
+
#
|
63
|
+
# @return [Array<Month>] 特定月
|
64
|
+
#
|
65
|
+
def specify(context:, years: [], start_date: Western::Calendar.new,
|
66
|
+
last_date: Western::Calendar.new)
|
67
|
+
result = []
|
68
|
+
years.each do |year|
|
69
|
+
result |= specify_month(
|
70
|
+
context: context, year: year, start_date: start_date, last_date: last_date
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
result
|
75
|
+
end
|
94
76
|
|
95
|
-
|
96
|
-
monthly_last_date = month.last_date.clone
|
77
|
+
# :reek:TooManyStatements { max_statements: 7 }
|
97
78
|
|
98
|
-
|
79
|
+
#
|
80
|
+
# 月を特定する
|
81
|
+
#
|
82
|
+
# @param [Context::Context] context 暦コンテキスト
|
83
|
+
# @param [Calculation::Base::Year] year 年
|
84
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
85
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
86
|
+
#
|
87
|
+
# @return [Month] 対象月
|
88
|
+
#
|
89
|
+
def specify_month(context:, year:, start_date: Western::Calendar.new,
|
90
|
+
last_date: Western::Calendar.new)
|
91
|
+
months = year.months
|
99
92
|
|
100
|
-
|
93
|
+
specify_months = []
|
94
|
+
months.each do |month|
|
95
|
+
next unless include?(month: month, start_date: start_date, last_date: last_date)
|
101
96
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
97
|
+
monthly_start_date = month.western_date.clone
|
98
|
+
monthly_last_date = month.last_date.clone
|
99
|
+
|
100
|
+
monthly_start_date = start_date.clone if start_date > monthly_start_date
|
101
|
+
|
102
|
+
monthly_last_date = last_date.clone if last_date < monthly_last_date
|
103
|
+
|
104
|
+
specify_months.push(
|
105
|
+
Month.new(context: context, year: year, month: month,
|
106
|
+
start_date: monthly_start_date, last_date: monthly_last_date)
|
107
|
+
)
|
108
|
+
end
|
109
|
+
|
110
|
+
specify_months
|
106
111
|
end
|
107
112
|
|
108
|
-
|
109
|
-
|
110
|
-
|
113
|
+
#
|
114
|
+
# 月が範囲に含まれるか
|
115
|
+
#
|
116
|
+
# @param [Calculation::Monthly::Month] month 月
|
117
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
118
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
119
|
+
#
|
120
|
+
# @return [True] 含む
|
121
|
+
# @return [False] 含まない
|
122
|
+
#
|
123
|
+
def include?(month:, start_date:, last_date:)
|
124
|
+
monthly_start_date = month.western_date.clone
|
125
|
+
monthly_last_date = month.last_date.clone
|
111
126
|
|
112
|
-
|
113
|
-
# 月が範囲に含まれるか
|
114
|
-
#
|
115
|
-
# @param [Calculation::Monthly::Month] month 月
|
116
|
-
# @param [Western::Calendar] start_date 西暦開始日
|
117
|
-
# @param [Western::Calendar] last_date 西暦終了日
|
118
|
-
#
|
119
|
-
# @return [True] 含む
|
120
|
-
# @return [False] 含まない
|
121
|
-
#
|
122
|
-
def self.include?(month:, start_date:, last_date:)
|
123
|
-
monthly_start_date = month.western_date.clone
|
124
|
-
monthly_last_date = month.last_date.clone
|
127
|
+
return false if monthly_start_date.invalid?
|
125
128
|
|
126
|
-
|
129
|
+
return false if monthly_last_date.invalid?
|
127
130
|
|
128
|
-
|
131
|
+
return false if under(monthly_start_date: monthly_start_date,
|
132
|
+
start_date: start_date, last_date: last_date)
|
129
133
|
|
130
|
-
|
131
|
-
|
134
|
+
return false if over(monthly_last_date: monthly_last_date,
|
135
|
+
start_date: start_date, last_date: last_date)
|
132
136
|
|
133
|
-
|
134
|
-
|
137
|
+
true
|
138
|
+
end
|
135
139
|
|
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
|
-
# @return [False] 後にない
|
164
|
-
#
|
165
|
-
def self.over(monthly_last_date:, start_date:, last_date:)
|
166
|
-
start_date > monthly_last_date && last_date > monthly_last_date
|
140
|
+
#
|
141
|
+
# 範囲が月より前にあるか
|
142
|
+
#
|
143
|
+
# @param [Western::Calendar] monthly_start_date 月初日
|
144
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
145
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
146
|
+
#
|
147
|
+
# @return [True] 前にある
|
148
|
+
# @return [False] 前にない
|
149
|
+
#
|
150
|
+
def under(monthly_start_date:, start_date:, last_date:)
|
151
|
+
start_date < monthly_start_date && last_date < monthly_start_date
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# 範囲が月より後にあるか
|
156
|
+
#
|
157
|
+
# @param [Western::Calendar] monthly_start_date 月末日
|
158
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
159
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
160
|
+
#
|
161
|
+
# @return [True] 後にある
|
162
|
+
# @return [False] 後にない
|
163
|
+
#
|
164
|
+
def over(monthly_last_date:, start_date:, last_date:)
|
165
|
+
start_date > monthly_last_date && last_date > monthly_last_date
|
166
|
+
end
|
167
167
|
end
|
168
|
-
private_class_method :over
|
169
168
|
end
|
170
169
|
end
|
171
170
|
end
|