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