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
@@ -25,142 +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
|
-
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
|
+
)
|
45
44
|
|
46
|
-
|
47
|
-
|
45
|
+
result = []
|
46
|
+
months.each do |month|
|
47
|
+
result |= month.get
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
# 年を特定する
|
51
|
-
#
|
52
|
-
# @param [Array<Year>] years 範囲
|
53
|
-
# @param [Western::Calendar] start_date 西暦開始日
|
54
|
-
# @param [Western::Calendar] last_date 西暦終了日
|
55
|
-
#
|
56
|
-
# @return [Array<Month>] 特定月
|
57
|
-
#
|
58
|
-
def self.specify(years: [], start_date: Western::Calendar.new,
|
59
|
-
last_date: Western::Calendar.new)
|
60
|
-
result = []
|
61
|
-
years.each do |year|
|
62
|
-
result |= specify_month(
|
63
|
-
year: year, start_date: start_date, last_date: last_date
|
64
|
-
)
|
50
|
+
result
|
65
51
|
end
|
66
52
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
89
76
|
|
90
|
-
|
91
|
-
monthly_last_date = month.last_date.clone
|
77
|
+
# :reek:TooManyStatements { max_statements: 7 }
|
92
78
|
|
93
|
-
|
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
|
94
92
|
|
95
|
-
|
93
|
+
specify_months = []
|
94
|
+
months.each do |month|
|
95
|
+
next unless include?(month: month, start_date: start_date, last_date: last_date)
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
101
111
|
end
|
102
112
|
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
106
126
|
|
107
|
-
|
108
|
-
# 月が範囲に含まれるか
|
109
|
-
#
|
110
|
-
# @param [Monthly::Month] month 月
|
111
|
-
# @param [Western::Calendar] start_date 西暦開始日
|
112
|
-
# @param [Western::Calendar] last_date 西暦終了日
|
113
|
-
#
|
114
|
-
# @return [True] 含む
|
115
|
-
# @return [False] 含まない
|
116
|
-
#
|
117
|
-
def self.include?(month:, start_date:, last_date:)
|
118
|
-
monthly_start_date = month.western_date.clone
|
119
|
-
monthly_last_date = month.last_date.clone
|
127
|
+
return false if monthly_start_date.invalid?
|
120
128
|
|
121
|
-
|
129
|
+
return false if monthly_last_date.invalid?
|
122
130
|
|
123
|
-
|
131
|
+
return false if under(monthly_start_date: monthly_start_date,
|
132
|
+
start_date: start_date, last_date: last_date)
|
124
133
|
|
125
|
-
|
126
|
-
|
134
|
+
return false if over(monthly_last_date: monthly_last_date,
|
135
|
+
start_date: start_date, last_date: last_date)
|
127
136
|
|
128
|
-
|
129
|
-
|
137
|
+
true
|
138
|
+
end
|
130
139
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
# @return [False] 後にない
|
159
|
-
#
|
160
|
-
def self.over(monthly_last_date:, start_date:, last_date:)
|
161
|
-
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
|
162
167
|
end
|
163
|
-
private_class_method :over
|
164
168
|
end
|
165
169
|
end
|
166
170
|
end
|
@@ -6,6 +6,9 @@ require_relative '../../../../output/logger'
|
|
6
6
|
|
7
7
|
require_relative '../../../base/year'
|
8
8
|
|
9
|
+
require_relative '../../internal/day'
|
10
|
+
require_relative '../../internal/option'
|
11
|
+
|
9
12
|
# :nodoc:
|
10
13
|
module Zakuro
|
11
14
|
# :nodoc:
|
@@ -23,68 +26,72 @@ module Zakuro
|
|
23
26
|
# @return [Output::Logger] ロガー
|
24
27
|
LOGGER = Output::Logger.new(location: 'specifier')
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
param: Output::Response::SingleDay::Param.new(
|
40
|
-
year: year, month: month,
|
41
|
-
date: date, days: date - first_date
|
42
|
-
)
|
43
|
-
)
|
44
|
-
end
|
29
|
+
class << self
|
30
|
+
#
|
31
|
+
# 取得する
|
32
|
+
#
|
33
|
+
# @param [Array<Calculation::Base::Year>] years 範囲
|
34
|
+
# @param [Western::Calendar] date 西暦日
|
35
|
+
#
|
36
|
+
# @return [Result::Data::SingleDay] 和暦日
|
37
|
+
#
|
38
|
+
def get(years: [], date: Western::Calendar.new)
|
39
|
+
year, month = specify(years: years, date: date)
|
40
|
+
|
41
|
+
day = Day.get(month: month, date: date)
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
# @return [Base::Year] 対象年
|
53
|
-
# @return [Monthly::Month] 対象月
|
54
|
-
#
|
55
|
-
def self.specify(years:, date:)
|
56
|
-
years.each do |year|
|
57
|
-
month = specify_month(year: year, date: date)
|
58
|
-
return year, month unless month.invalid?
|
43
|
+
options = Option.create(month: month, day: day)
|
44
|
+
|
45
|
+
Output::Response::SingleDay.create(
|
46
|
+
year: year, month: month, day: day, options: options
|
47
|
+
)
|
59
48
|
end
|
60
49
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
return month if month.include?(date: date)
|
50
|
+
private
|
51
|
+
|
52
|
+
#
|
53
|
+
# 年を特定する
|
54
|
+
#
|
55
|
+
# @param [Array<Year>] years 範囲
|
56
|
+
# @param [Western::Calendar] date 西暦日
|
57
|
+
#
|
58
|
+
# @return [Base::Year] 対象年
|
59
|
+
# @return [Monthly::Month] 対象月
|
60
|
+
#
|
61
|
+
# @raise [ArgumentError] 引数エラー
|
62
|
+
#
|
63
|
+
def specify(years:, date:)
|
64
|
+
years.each do |year|
|
65
|
+
month = specify_month(year: year, date: date)
|
66
|
+
return year, month unless month.invalid?
|
67
|
+
end
|
68
|
+
|
69
|
+
raise ArgumentError, "invalid year range. date: #{date.format}"
|
83
70
|
end
|
84
71
|
|
85
|
-
|
72
|
+
# :reek:TooManyStatements { max_statements: 7 }
|
73
|
+
|
74
|
+
#
|
75
|
+
# 月を特定する
|
76
|
+
#
|
77
|
+
# @param [Base::Year] year 年
|
78
|
+
# @param [Western::Calendar] date 西暦日
|
79
|
+
#
|
80
|
+
# @return [Monthly::Month] 対象月
|
81
|
+
#
|
82
|
+
def specify_month(year:, date:)
|
83
|
+
months = year.months
|
84
|
+
|
85
|
+
months.each do |month|
|
86
|
+
western_date = month.western_date
|
87
|
+
next if western_date.invalid?
|
88
|
+
|
89
|
+
return month if month.include?(date: date)
|
90
|
+
end
|
91
|
+
|
92
|
+
Monthly::Month.new
|
93
|
+
end
|
86
94
|
end
|
87
|
-
private_class_method :specify_month
|
88
95
|
end
|
89
96
|
end
|
90
97
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
# :nodoc:
|
6
|
+
module Calculation
|
7
|
+
# :nodoc:
|
8
|
+
module Type
|
9
|
+
#
|
10
|
+
# Optional 参照管理
|
11
|
+
#
|
12
|
+
# * インスタンスのnil操作を避ける
|
13
|
+
# * safe navigation operator を使用しない
|
14
|
+
#
|
15
|
+
class Optional
|
16
|
+
#
|
17
|
+
# 初期化
|
18
|
+
#
|
19
|
+
# @param [Object] obj インスタンス
|
20
|
+
#
|
21
|
+
def initialize(obj: nil)
|
22
|
+
@obj = obj
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# インスタンスを取得する
|
27
|
+
#
|
28
|
+
# @return [Object] インスタンス
|
29
|
+
#
|
30
|
+
def get
|
31
|
+
@obj
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# 不正か
|
36
|
+
#
|
37
|
+
# @return [True] 不正
|
38
|
+
# @return [False] 不正なし
|
39
|
+
#
|
40
|
+
def invalid?
|
41
|
+
@obj.nil?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|