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
@@ -14,159 +14,125 @@ module Zakuro
|
|
14
14
|
# SingleDay 1日データ
|
15
15
|
#
|
16
16
|
module SingleDay
|
17
|
-
|
18
|
-
# Param 引数
|
19
|
-
#
|
20
|
-
class Param
|
21
|
-
# @return [Year] 年情報(各暦のデータ型)
|
22
|
-
attr_reader :year
|
23
|
-
# @return [Month] 月情報(各暦のデータ型)
|
24
|
-
attr_reader :month
|
25
|
-
# @return [Western::Calendar] 年月日情報(西暦)
|
26
|
-
attr_reader :date
|
27
|
-
# @return [Integer] 日数(月初日から指定日までの日数)
|
28
|
-
attr_reader :days
|
29
|
-
|
17
|
+
class << self
|
30
18
|
#
|
31
|
-
#
|
19
|
+
# 1日データを生成する
|
32
20
|
#
|
33
|
-
# @param [Year] year 年情報(各暦のデータ型)
|
34
|
-
# @param [Month] month 月情報(各暦のデータ型)
|
35
|
-
# @param [
|
36
|
-
# @param [
|
21
|
+
# @param [Calculation::Base::Year] year 年情報(各暦のデータ型)
|
22
|
+
# @param [Calculation::Monthly::Month] month 月情報(各暦のデータ型)
|
23
|
+
# @param [Calculation::Base::Day] day 日情報
|
24
|
+
# @param [Hash<String, Result::Data::Option::AbstractOption>] options オプション
|
37
25
|
#
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
26
|
+
# @return [Result::Data::SingleDay] 1日データ
|
27
|
+
#
|
28
|
+
def create(year:, month:, day:, options: {})
|
29
|
+
Result::Data::SingleDay.new(
|
30
|
+
year: save_year(year: year, month: month, day: day),
|
31
|
+
month: save_month(month: month, day: day),
|
32
|
+
day: save_day(day: day),
|
33
|
+
options: options
|
34
|
+
)
|
43
35
|
end
|
44
|
-
end
|
45
36
|
|
46
|
-
|
47
|
-
# 1日データを生成する
|
48
|
-
#
|
49
|
-
# @param [Parameter] param 引数
|
50
|
-
#
|
51
|
-
# @return [SingleDay] 1日データ
|
52
|
-
#
|
53
|
-
def self.save_single_day(param:)
|
54
|
-
year = param.year
|
55
|
-
month = param.month
|
56
|
-
date = param.date
|
57
|
-
days = param.days
|
58
|
-
Result::Data::SingleDay.new(
|
59
|
-
year: save_year(year: year, month: month, date: date),
|
60
|
-
month: save_month(month: month, date: date, days: days),
|
61
|
-
day: save_day(month: month, date: date, days: days)
|
62
|
-
)
|
63
|
-
end
|
37
|
+
private
|
64
38
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
39
|
+
#
|
40
|
+
# 年データを保存する
|
41
|
+
#
|
42
|
+
# @param [Calculation::Base::Year] year 年情報(各暦のデータ型)
|
43
|
+
# @param [Calculation::Monthly::Month] month 月情報(各暦のデータ型)
|
44
|
+
# @param [Calculation::Base::Day] day 日情報
|
45
|
+
#
|
46
|
+
# @return [Result::Year] 年データ
|
47
|
+
#
|
48
|
+
def save_year(year:, month:, day:)
|
49
|
+
gengou = month.gengou
|
50
|
+
date = day.western_date
|
51
|
+
first = gengou.match_first_line(date: date)
|
52
|
+
second = gengou.match_second_line(date: date)
|
53
|
+
Result::Data::Year.new(
|
54
|
+
first_gengou:
|
55
|
+
Result::Data::Gengou.new(name: first.name, number: first.year),
|
56
|
+
second_gengou:
|
57
|
+
Result::Data::Gengou.new(name: second.name, number: second.year),
|
58
|
+
zodiac_name: year.zodiac_name, total_days: year.total_days
|
59
|
+
)
|
60
|
+
end
|
85
61
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
private_class_method :save_month
|
62
|
+
#
|
63
|
+
# 月データを保存する
|
64
|
+
#
|
65
|
+
# @param [Calculation::Monthly::Month] month 月情報(各暦のデータ型)
|
66
|
+
# @param [Calculation::Base::Day] day 日情報
|
67
|
+
#
|
68
|
+
# @return [Result::Month] 月データ
|
69
|
+
#
|
70
|
+
def save_month(month:, day:)
|
71
|
+
Result::Data::Month.new(
|
72
|
+
number: month.number, leaped: month.leaped?, days_name: month.days_name,
|
73
|
+
first_day: save_first_day(remainder: month.remainder,
|
74
|
+
date: day.western_date, days: day.number - 1),
|
75
|
+
odd_solar_terms: save_solar_term(term: month.odd_term),
|
76
|
+
even_solar_terms: save_solar_term(term: month.even_term)
|
77
|
+
)
|
78
|
+
end
|
105
79
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
80
|
+
#
|
81
|
+
# 月初日データを保存する
|
82
|
+
#
|
83
|
+
# @param [Cycle::AbstractRemainder] remainder 大余小余情報
|
84
|
+
# @param [Western::Calendar] date 年月日情報(西暦)
|
85
|
+
# @param [Integer] days 日数(月初日から指定日までの日数)
|
86
|
+
#
|
87
|
+
# @return [Result::Day] 日データ
|
88
|
+
#
|
89
|
+
def save_first_day(remainder:, date:, days:)
|
90
|
+
western_date = date.clone - days
|
91
|
+
Result::Data::Day.new(
|
92
|
+
number: 1,
|
93
|
+
zodiac_name: remainder.zodiac_name,
|
94
|
+
remainder: remainder,
|
95
|
+
western_date: western_date
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# 二十四節気データを保存する
|
101
|
+
#
|
102
|
+
# @note 今は宣明暦に合わせている。江戸期以降の暦には対応していない(複数の中気節気を指定できない)
|
103
|
+
#
|
104
|
+
# @param [SolarTerm] term 二十四節気情報(各暦のデータ型)
|
105
|
+
#
|
106
|
+
# @return [Array<Result::SolarTerm>] 二十四節気データ
|
107
|
+
#
|
108
|
+
def save_solar_term(term:)
|
109
|
+
return [] if term.invalid?
|
125
110
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
# @return [Array<Result::SolarTerm>] 二十四節気データ
|
134
|
-
#
|
135
|
-
def self.save_solar_term(term:)
|
136
|
-
return [] if term.invalid?
|
111
|
+
[
|
112
|
+
Result::Data::SolarTerm.new(
|
113
|
+
index: term.index,
|
114
|
+
remainder: term.remainder
|
115
|
+
)
|
116
|
+
]
|
117
|
+
end
|
137
118
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
119
|
+
#
|
120
|
+
# 日データを保存する
|
121
|
+
#
|
122
|
+
# @param [Calculation::Base::Day] day 日情報
|
123
|
+
#
|
124
|
+
# @return [Result::Day] 日データ
|
125
|
+
#
|
126
|
+
def save_day(day:)
|
127
|
+
remainder = day.remainder
|
128
|
+
Result::Data::Day.new(
|
129
|
+
number: day.number,
|
130
|
+
zodiac_name: remainder.zodiac_name,
|
131
|
+
remainder: remainder,
|
132
|
+
western_date: day.western_date
|
142
133
|
)
|
143
|
-
|
144
|
-
end
|
145
|
-
private_class_method :save_solar_term
|
146
|
-
|
147
|
-
#
|
148
|
-
# 日データを保存する
|
149
|
-
#
|
150
|
-
# @param [Month] month 月情報(各暦のデータ型)
|
151
|
-
# @param [Western::Calendar] date 年月日情報(西暦)
|
152
|
-
# @param [Integer] days 日数(月初日から指定日までの日数)
|
153
|
-
#
|
154
|
-
# @return [Result::Day] 日データ
|
155
|
-
#
|
156
|
-
def self.save_day(month:, date:, days:)
|
157
|
-
remainder = month.remainder
|
158
|
-
remainder = remainder.add(
|
159
|
-
# 常に参照元のRemainderクラスで生成する
|
160
|
-
remainder.class.new(day: days, minute: 0, second: 0)
|
161
|
-
)
|
162
|
-
Result::Data::Day.new(
|
163
|
-
number: (days + 1),
|
164
|
-
zodiac_name: remainder.zodiac_name,
|
165
|
-
remainder: remainder,
|
166
|
-
western_date: date
|
167
|
-
)
|
134
|
+
end
|
168
135
|
end
|
169
|
-
private_class_method :save_day
|
170
136
|
end
|
171
137
|
end
|
172
138
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
#
|
6
|
+
# Result 演算結果
|
7
|
+
#
|
8
|
+
module Result
|
9
|
+
#
|
10
|
+
# データ部
|
11
|
+
#
|
12
|
+
module Data
|
13
|
+
#
|
14
|
+
# Option オプション
|
15
|
+
#
|
16
|
+
module Option
|
17
|
+
#
|
18
|
+
# AbstractOption 抽象オプション結果
|
19
|
+
#
|
20
|
+
class AbstractOption
|
21
|
+
# @return [True] オプション値有
|
22
|
+
# @return [False] オプション値無
|
23
|
+
attr_reader :matched
|
24
|
+
|
25
|
+
#
|
26
|
+
# 初期化
|
27
|
+
#
|
28
|
+
# @param [True, False] matched オプション値有無
|
29
|
+
#
|
30
|
+
def initialize(matched: false)
|
31
|
+
@matched = matched
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './solar_term'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
#
|
8
|
+
# Result 演算結果
|
9
|
+
#
|
10
|
+
module Result
|
11
|
+
#
|
12
|
+
# データ部
|
13
|
+
#
|
14
|
+
module Data
|
15
|
+
#
|
16
|
+
# Option オプション
|
17
|
+
#
|
18
|
+
module Option
|
19
|
+
#
|
20
|
+
# DroppedDate 没日
|
21
|
+
#
|
22
|
+
module DroppedDate
|
23
|
+
#
|
24
|
+
# Calculation 演算値
|
25
|
+
#
|
26
|
+
class Calculation
|
27
|
+
# @return [String] 大余小余(没余)
|
28
|
+
attr_reader :remainder
|
29
|
+
# @return [SolarTerm] 二十四節気
|
30
|
+
attr_reader :solar_term
|
31
|
+
|
32
|
+
#
|
33
|
+
# 初期化
|
34
|
+
#
|
35
|
+
# @param [String] remainder 大余小余(没余)
|
36
|
+
# @param [SolarTerm] solar_term 二十四節気
|
37
|
+
#
|
38
|
+
def initialize(remainder: '', solar_term: SolarTerm.new)
|
39
|
+
@remainder = remainder
|
40
|
+
@solar_term = solar_term
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../abstract_option'
|
4
|
+
|
5
|
+
require_relative './calculation'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
#
|
10
|
+
# Result 演算結果
|
11
|
+
#
|
12
|
+
module Result
|
13
|
+
#
|
14
|
+
# データ部
|
15
|
+
#
|
16
|
+
module Data
|
17
|
+
#
|
18
|
+
# Option オプション
|
19
|
+
#
|
20
|
+
module Option
|
21
|
+
#
|
22
|
+
# DroppedDate 没日
|
23
|
+
#
|
24
|
+
module DroppedDate
|
25
|
+
#
|
26
|
+
# Option 没日集約
|
27
|
+
#
|
28
|
+
class Option < AbstractOption
|
29
|
+
# @return [Calculation] 演算値
|
30
|
+
attr_reader :calculation
|
31
|
+
|
32
|
+
#
|
33
|
+
# 初期化
|
34
|
+
#
|
35
|
+
# @param [True, False] matched オプション値有無
|
36
|
+
# @param [Calculation] calculation 演算値
|
37
|
+
#
|
38
|
+
def initialize(matched: false, calculation: Calculation.new)
|
39
|
+
super(matched: matched)
|
40
|
+
@calculation = calculation
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
#
|
6
|
+
# Result 演算結果
|
7
|
+
#
|
8
|
+
module Result
|
9
|
+
#
|
10
|
+
# データ部
|
11
|
+
#
|
12
|
+
module Data
|
13
|
+
#
|
14
|
+
# Option オプション
|
15
|
+
#
|
16
|
+
module Option
|
17
|
+
#
|
18
|
+
# DroppedDate 没日
|
19
|
+
#
|
20
|
+
module DroppedDate
|
21
|
+
#
|
22
|
+
# SolarTerm 二十四節気
|
23
|
+
#
|
24
|
+
class SolarTerm
|
25
|
+
# @return [Interger] 不正連番
|
26
|
+
INVALID = -1
|
27
|
+
|
28
|
+
# @return [Integer] 連番
|
29
|
+
attr_reader :index
|
30
|
+
# @return [String] 大余小余
|
31
|
+
attr_reader :remainder
|
32
|
+
|
33
|
+
#
|
34
|
+
# 初期化
|
35
|
+
#
|
36
|
+
# @param [Integer] index 連番
|
37
|
+
# @param [String] remainder 大余小余
|
38
|
+
#
|
39
|
+
def initialize(index: INVALID, remainder: '')
|
40
|
+
@index = index
|
41
|
+
@remainder = remainder
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
require_relative '../core'
|
4
4
|
|
5
|
+
require_relative './option/abstract_option'
|
6
|
+
|
7
|
+
require_relative './option/dropped_date/option'
|
8
|
+
|
5
9
|
require_relative 'year'
|
6
10
|
|
7
11
|
require_relative 'month'
|
@@ -28,6 +32,8 @@ module Zakuro
|
|
28
32
|
attr_reader :month
|
29
33
|
# @return [Day] 日
|
30
34
|
attr_reader :day
|
35
|
+
# @return [Hash<String, Option::AbstractOption>] オプション
|
36
|
+
attr_reader :options
|
31
37
|
|
32
38
|
#
|
33
39
|
# 初期化
|
@@ -35,12 +41,14 @@ module Zakuro
|
|
35
41
|
# @param [Year] year 年
|
36
42
|
# @param [Month] month 月
|
37
43
|
# @param [Day] day 日
|
44
|
+
# @param [Hash<String, Option::AbstractOption>] options オプション
|
38
45
|
#
|
39
|
-
def initialize(year:, month:, day:)
|
46
|
+
def initialize(year:, month:, day:, options: {})
|
40
47
|
super
|
41
48
|
@year = year
|
42
49
|
@month = month
|
43
50
|
@day = day
|
51
|
+
@options = options
|
44
52
|
end
|
45
53
|
end
|
46
54
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './month/history'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
#
|
8
|
+
# Result 演算結果
|
9
|
+
#
|
10
|
+
module Result
|
11
|
+
#
|
12
|
+
# 運用情報
|
13
|
+
#
|
14
|
+
class Operation
|
15
|
+
#
|
16
|
+
# Month 運用情報(月)
|
17
|
+
#
|
18
|
+
class Month
|
19
|
+
# @return [History] 月別履歴情報(当月)
|
20
|
+
attr_reader :current
|
21
|
+
# @return [History] 月別履歴情報(影響を与えた月)
|
22
|
+
attr_reader :parent
|
23
|
+
|
24
|
+
def initialize(current: History.new, parent: History.new)
|
25
|
+
@current = current
|
26
|
+
@parent = parent
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './data/single_day'
|
4
|
+
|
5
|
+
require_relative './operation/month'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
#
|
10
|
+
# Result 演算結果
|
11
|
+
#
|
12
|
+
module Result
|
13
|
+
#
|
14
|
+
# Operation 運用情報
|
15
|
+
#
|
16
|
+
class Operation
|
17
|
+
# @return [True] 運用あり
|
18
|
+
# @return [False] 運用なし
|
19
|
+
attr_reader :operated
|
20
|
+
# @return [Month] 月別履歴情報
|
21
|
+
attr_reader :month
|
22
|
+
# @return [Data::SingleDay] 計算値
|
23
|
+
attr_reader :original
|
24
|
+
|
25
|
+
#
|
26
|
+
# 初期化
|
27
|
+
#
|
28
|
+
# @param [True, False] operated 運用有無
|
29
|
+
# @param [Month] month 月別履歴情報
|
30
|
+
# @param [Data::SingleDay] original 計算値
|
31
|
+
#
|
32
|
+
def initialize(operated:, month:, original:)
|
33
|
+
@operated = operated
|
34
|
+
@month = month
|
35
|
+
@original = original
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/zakuro/result/result.rb
CHANGED
@@ -4,7 +4,7 @@ require 'json'
|
|
4
4
|
|
5
5
|
require_relative './data/single_day'
|
6
6
|
|
7
|
-
require_relative './operation
|
7
|
+
require_relative './operation'
|
8
8
|
|
9
9
|
require_relative './core'
|
10
10
|
|
@@ -20,14 +20,14 @@ module Zakuro
|
|
20
20
|
class Single < Core
|
21
21
|
# @return [Data::SingleDay] 1日
|
22
22
|
attr_reader :data
|
23
|
-
# @return [Operation
|
23
|
+
# @return [Operation] 運用情報
|
24
24
|
attr_reader :operation
|
25
25
|
|
26
26
|
#
|
27
27
|
# 初期化
|
28
28
|
#
|
29
29
|
# @param [Data::SingleDay] data 1日
|
30
|
-
# @param [Operation
|
30
|
+
# @param [Operation] operation 運用情報
|
31
31
|
#
|
32
32
|
def initialize(data:, operation:)
|
33
33
|
super
|