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
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../context/option'
|
4
|
+
require_relative '../../../result/data/option/dropped_date/option'
|
5
|
+
require_relative '../../../result/data/solar_term'
|
6
|
+
|
7
|
+
require_relative '../../option/dropped_date/location'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Calculation
|
13
|
+
# :nodoc:
|
14
|
+
module Summary
|
15
|
+
#
|
16
|
+
# Option オプション
|
17
|
+
#
|
18
|
+
module Option
|
19
|
+
class << self
|
20
|
+
#
|
21
|
+
# 初期化
|
22
|
+
#
|
23
|
+
# @param [Calculation::Monthly::Month] month 月情報(各暦のデータ型)
|
24
|
+
# @param [Calculation::Base::Day] day 日情報
|
25
|
+
#
|
26
|
+
# @return [Hash<String, Result::Data::Option::AbstractOption>] オプション結果
|
27
|
+
#
|
28
|
+
def create(month:, day:)
|
29
|
+
options = {}
|
30
|
+
context = month.context
|
31
|
+
|
32
|
+
if context.option.dropped_date?
|
33
|
+
remainder = day.remainder
|
34
|
+
solar_terms = month.solar_terms
|
35
|
+
option = dropped_date(
|
36
|
+
context: context, remainder: remainder, solar_terms: solar_terms
|
37
|
+
)
|
38
|
+
options[Context::Option::DROPPED_DATE_KEY] = option
|
39
|
+
end
|
40
|
+
|
41
|
+
options
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
#
|
47
|
+
# 没日を求める
|
48
|
+
#
|
49
|
+
# @param [Context::Context] context 暦コンテキスト
|
50
|
+
# @param [Cycle::AbstractRemainder] remainder 当日和暦日
|
51
|
+
# @param [Array<Cycle::AbstractSolarTerm>] solar_terms 二十四節気
|
52
|
+
#
|
53
|
+
# @return [Result::Data::Option::DroppedDate::Option] 没日
|
54
|
+
#
|
55
|
+
def dropped_date(context:, remainder:, solar_terms:)
|
56
|
+
option = Result::Data::Option::DroppedDate::Option.new(
|
57
|
+
matched: false,
|
58
|
+
calculation: Result::Data::Option::DroppedDate::Calculation.new
|
59
|
+
)
|
60
|
+
|
61
|
+
return option if remainder.invalid?
|
62
|
+
|
63
|
+
location = Calculation::Option::DroppedDate::Location.new(
|
64
|
+
context: context, solar_terms: solar_terms
|
65
|
+
)
|
66
|
+
|
67
|
+
return option unless location.exist?
|
68
|
+
|
69
|
+
dropped_date = location.get
|
70
|
+
|
71
|
+
return option unless remainder.day == dropped_date.day
|
72
|
+
|
73
|
+
dropped_date_option(location: location)
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# 没日オプション値を生成する
|
78
|
+
#
|
79
|
+
# @param [Calculation::Option::DroppedDate::Location] location 没日位置
|
80
|
+
#
|
81
|
+
# @return [Result::Data::Option::DroppedDate::Option] 没日オプション値
|
82
|
+
#
|
83
|
+
def dropped_date_option(location:)
|
84
|
+
dropped_date = location.get
|
85
|
+
solar_term = location.solar_term
|
86
|
+
Result::Data::Option::DroppedDate::Option.new(
|
87
|
+
matched: true,
|
88
|
+
calculation: Result::Data::Option::DroppedDate::Calculation.new(
|
89
|
+
remainder: dropped_date.format,
|
90
|
+
solar_term: Result::Data::SolarTerm.new(
|
91
|
+
index: solar_term.index,
|
92
|
+
remainder: solar_term.remainder.format
|
93
|
+
)
|
94
|
+
)
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -10,6 +10,8 @@ require_relative '../internal/operation'
|
|
10
10
|
|
11
11
|
require_relative './specifier/single_day'
|
12
12
|
|
13
|
+
require_relative './specifier/specified_range'
|
14
|
+
|
13
15
|
# :nodoc:
|
14
16
|
module Zakuro
|
15
17
|
# :nodoc:
|
@@ -22,128 +24,153 @@ module Zakuro
|
|
22
24
|
# Range 期間
|
23
25
|
#
|
24
26
|
module Range
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
27
|
+
class << self
|
28
|
+
#
|
29
|
+
# 生成する
|
30
|
+
#
|
31
|
+
# @param [Context::Context] context 暦コンテキスト
|
32
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
33
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
34
|
+
#
|
35
|
+
# @return [Result::Range] 期間検索結果(和暦日)
|
36
|
+
#
|
37
|
+
def get(context:, start_date: Japan::Calendar.new,
|
38
|
+
last_date: Japan::Calendar.new)
|
39
|
+
years = get_full_range_years(
|
40
|
+
context: context, start_date: start_date, last_date: last_date
|
41
|
+
)
|
42
|
+
operated_years = get_operation_range_years(
|
43
|
+
context: context, years: years, start_date: start_date, last_date: last_date
|
44
|
+
)
|
53
45
|
|
54
|
-
|
55
|
-
|
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
|
-
)
|
46
|
+
range = specified_range(
|
47
|
+
operated_years: operated_years, start_date: start_date, last_date: last_date
|
143
48
|
)
|
49
|
+
|
50
|
+
list = create_list(
|
51
|
+
context: context,
|
52
|
+
operated_years: operated_years, years: years, range: range
|
53
|
+
)
|
54
|
+
|
55
|
+
Result::Range.new(list: list)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
#
|
61
|
+
# 特定範囲を取得する
|
62
|
+
#
|
63
|
+
# @param [Array<Base::OperatedYear>] operated_years 運用結果範囲
|
64
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
65
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
66
|
+
#
|
67
|
+
# @return [SpecifiedRange] 特定範囲
|
68
|
+
#
|
69
|
+
def specified_range(operated_years: [], start_date: Japan::Calendar.new,
|
70
|
+
last_date: Japan::Calendar.new)
|
71
|
+
japan_start_date = Specifier::SingleDay.get(
|
72
|
+
years: operated_years, date: start_date
|
73
|
+
)
|
74
|
+
japan_last_date = Specifier::SingleDay.get(
|
75
|
+
years: operated_years, date: last_date
|
76
|
+
)
|
77
|
+
|
78
|
+
SpecifiedRange.new(start_date: japan_start_date, last_date: japan_last_date)
|
144
79
|
end
|
145
80
|
|
146
|
-
|
81
|
+
#
|
82
|
+
# 1日検索結果リストを生成する
|
83
|
+
#
|
84
|
+
# @param [Context::Context] context 暦コンテキスト
|
85
|
+
# @param [Array<Base::OperatedYear>] operated_years 運用結果範囲
|
86
|
+
# @param [Array<Base::Year>] years 完全範囲
|
87
|
+
# @param [SpecifiedRange] range 特定範囲
|
88
|
+
#
|
89
|
+
# @return [Array<Result::Single>] 結果リスト
|
90
|
+
#
|
91
|
+
def create_list(context:, operated_years: [], years: [],
|
92
|
+
range:)
|
93
|
+
western_start_date = range.start_date.day.western_date
|
94
|
+
western_last_date = range.last_date.day.western_date
|
95
|
+
|
96
|
+
operated_dates = Western::Specifier::MultipleDay.get(
|
97
|
+
context: context, years: operated_years,
|
98
|
+
start_date: western_start_date, last_date: western_last_date
|
99
|
+
)
|
100
|
+
|
101
|
+
dates = Western::Specifier::MultipleDay.get(
|
102
|
+
context: context, years: years,
|
103
|
+
start_date: western_start_date, last_date: western_last_date
|
104
|
+
)
|
105
|
+
|
106
|
+
create_result_list(dates: dates, operated_dates: operated_dates)
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# 完全範囲を取得する
|
111
|
+
#
|
112
|
+
# @param [Context::Context] context 暦コンテキスト
|
113
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
114
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
115
|
+
#
|
116
|
+
# @return [Array<Base::Year>] 完全範囲
|
117
|
+
#
|
118
|
+
def get_full_range_years(context:, start_date: Japan::Calendar.new,
|
119
|
+
last_date: Japan::Calendar.new)
|
120
|
+
full_range = Calculation::Range::NamedFullRange.new(
|
121
|
+
context: context, start_name: start_date.gengou, last_name: last_date.gengou
|
122
|
+
)
|
123
|
+
full_range.get
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# 運用結果範囲を取得する
|
128
|
+
#
|
129
|
+
# @param [Context::Context] context 暦コンテキスト
|
130
|
+
# @param [Array<Base::Year>] years 完全範囲
|
131
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
132
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
133
|
+
#
|
134
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
135
|
+
#
|
136
|
+
def get_operation_range_years(context:, years:, start_date: Japan::Calendar.new,
|
137
|
+
last_date: Japan::Calendar.new)
|
138
|
+
operation_range = Calculation::Range::NamedOperationRange.new(
|
139
|
+
context: context, years: years,
|
140
|
+
start_name: start_date.gengou, last_name: last_date.gengou
|
141
|
+
)
|
142
|
+
operation_range.get
|
143
|
+
end
|
144
|
+
|
145
|
+
#
|
146
|
+
# 結果リストを生成する
|
147
|
+
#
|
148
|
+
# @param [Array<Result::Data::SingleDay>] dates 検索結果(計算値)
|
149
|
+
# @param [Array<Result::Data::SingleDay>] operated_dates 検索結果(運用値)
|
150
|
+
#
|
151
|
+
# @return [Array<Result::Single>] 結果リスト
|
152
|
+
#
|
153
|
+
def create_result_list(dates:, operated_dates:)
|
154
|
+
result = []
|
155
|
+
|
156
|
+
return result if dates.size != operated_dates.size
|
157
|
+
|
158
|
+
(0..(dates.size - 1)).each do |index|
|
159
|
+
data = operated_dates[index]
|
160
|
+
|
161
|
+
date = dates[index]
|
162
|
+
operation = Operation.create(calc_date: date)
|
163
|
+
|
164
|
+
result.push(
|
165
|
+
Result::Single.new(
|
166
|
+
data: data,
|
167
|
+
operation: operation
|
168
|
+
)
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
result
|
173
|
+
end
|
147
174
|
end
|
148
175
|
end
|
149
176
|
end
|
@@ -22,95 +22,95 @@ module Zakuro
|
|
22
22
|
# Single 一日
|
23
23
|
#
|
24
24
|
module Single
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
25
|
+
class << self
|
26
|
+
#
|
27
|
+
# 生成する
|
28
|
+
#
|
29
|
+
# @param [Context::Context] context 暦コンテキスト
|
30
|
+
# @param [Japan::Calendar] date 和暦日
|
31
|
+
#
|
32
|
+
# @return [Result::Single] 一日検索結果(和暦日)
|
33
|
+
#
|
34
|
+
def get(context:, date: Japan::Calendar.new)
|
35
|
+
years = get_full_range_years(context: context, date: date)
|
46
36
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
37
|
+
data = get_data(context: context, years: years, date: date)
|
38
|
+
|
39
|
+
western_date = data.day.western_date
|
40
|
+
operation = get_operation(years: years, date: western_date)
|
41
|
+
|
42
|
+
Result::Single.new(
|
43
|
+
data: data,
|
44
|
+
operation: operation
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
#
|
51
|
+
# 完全範囲を取得する
|
52
|
+
#
|
53
|
+
# @param [Context::Context] context 暦コンテキスト
|
54
|
+
# @param [Japan::Calendar] date 和暦日
|
55
|
+
#
|
56
|
+
# @return [Array<Base::Year>] 完全範囲
|
57
|
+
#
|
58
|
+
def get_full_range_years(context:, date: Japan::Calendar.new)
|
59
|
+
full_range = Calculation::Range::NamedFullRange.new(
|
60
|
+
context: context, start_name: date.gengou
|
61
|
+
)
|
62
|
+
full_range.get
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# 1日を取得する
|
67
|
+
#
|
68
|
+
# @param [Context::Context] context 暦コンテキスト
|
69
|
+
# @param [Array<Base::Year>] years 完全範囲
|
70
|
+
# @param [Japan::Calendar] date 和暦日
|
71
|
+
#
|
72
|
+
# @return [Data::SingleDay] 1日
|
73
|
+
#
|
74
|
+
def get_data(context:, years:, date: Japan::Calendar.new)
|
75
|
+
operated_years = get_operation_range_years(context: context, years: years, date: date)
|
76
|
+
|
77
|
+
Specifier::SingleDay.get(
|
78
|
+
years: operated_years, date: date
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
#
|
83
|
+
# 運用結果範囲を取得する
|
84
|
+
#
|
85
|
+
# @param [Context::Context] context 暦コンテキスト
|
86
|
+
# @param [Array<Calculation::Base::Year>] years 完全範囲
|
87
|
+
# @param [Japan::Calendar] date 和暦日
|
88
|
+
#
|
89
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
90
|
+
#
|
91
|
+
def get_operation_range_years(context:, years:, date: Japan::Calendar.new)
|
92
|
+
operation_range = Calculation::Range::NamedOperationRange.new(
|
93
|
+
context: context, start_name: date.gengou, years: years
|
94
|
+
)
|
95
|
+
operation_range.get
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# 完全範囲を取得する
|
100
|
+
#
|
101
|
+
# @param [Array<Calculation::Base::Year>] years 完全範囲
|
102
|
+
# @param [Western::Calendar] date 和暦日
|
103
|
+
#
|
104
|
+
# @return [Array<Base::Year>] 完全範囲
|
105
|
+
#
|
106
|
+
def 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
|
112
113
|
end
|
113
|
-
private_class_method :get_operation
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|