zakuro 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
- data/lib/zakuro/calculation/base/year.rb +107 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +459 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +151 -0
- data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +120 -0
- data/lib/zakuro/calculation/monthly/month.rb +184 -0
- data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
- data/lib/zakuro/calculation/monthly/operated_month.rb +201 -0
- data/lib/zakuro/calculation/range/full_range.rb +210 -0
- data/lib/zakuro/calculation/range/operated_range.rb +134 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +76 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +142 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
- data/lib/zakuro/calculation/summary/single.rb +129 -0
- data/lib/zakuro/merchant.rb +2 -2
- data/lib/zakuro/output/error.rb +7 -6
- data/lib/zakuro/output/logger.rb +50 -49
- data/lib/zakuro/output/response.rb +145 -144
- data/lib/zakuro/tools/typeof.rb +2 -2
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/abstract_version.rb +1 -1
- data/lib/zakuro/version/context.rb +23 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +63 -0
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +31 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +186 -182
- data/lib/zakuro/version/senmyou/range/annual_range.rb +134 -129
- data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +5 -5
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +4 -4
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +27 -27
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +2 -2
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +4 -4
- data/lib/zakuro/version/version_class_resolver.rb +62 -0
- data/lib/zakuro/version_factory.rb +2 -2
- metadata +24 -22
- data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
- data/lib/zakuro/cycle/zodiac.rb +0 -103
- data/lib/zakuro/version/senmyou/base/era.rb +0 -83
- data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
- data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
- data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
- data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -148
- data/lib/zakuro/version/senmyou/base/year.rb +0 -104
- data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
- data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -119
- data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
- data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
- data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -196
- data/lib/zakuro/version/senmyou/range/full_range.rb +0 -194
- data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -126
- data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -181
- data/lib/zakuro/version/senmyou/range/western_date_allocation.rb +0 -68
- data/lib/zakuro/version/senmyou/range/year_boundary.rb +0 -138
- data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -102
- data/lib/zakuro/version/senmyou/summary/single.rb +0 -125
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# :nodoc:
|
4
|
-
module Zakuro
|
5
|
-
# :nodoc:
|
6
|
-
module Senmyou
|
7
|
-
#
|
8
|
-
# WesternDateAllocation 西暦日の割り当て
|
9
|
-
#
|
10
|
-
module WesternDateAllocation
|
11
|
-
#
|
12
|
-
# 月初日の西暦日を更新する
|
13
|
-
#
|
14
|
-
# @param [Array<Year>] years 完全範囲(月初日なし)
|
15
|
-
#
|
16
|
-
# @return [Array<Year>] 完全範囲(月初日あり)
|
17
|
-
#
|
18
|
-
def self.get(years:)
|
19
|
-
update_first_day(years: years)
|
20
|
-
|
21
|
-
years
|
22
|
-
end
|
23
|
-
|
24
|
-
#
|
25
|
-
# 月初日の西暦日を更新する
|
26
|
-
#
|
27
|
-
# @param [Array<Year>] years 完全範囲(月初日なし)
|
28
|
-
#
|
29
|
-
def self.update_first_day(years:)
|
30
|
-
years.each_with_index do |year, index|
|
31
|
-
new_year_date = year.new_year_date.clone
|
32
|
-
|
33
|
-
months = year.months
|
34
|
-
update_first_day_within_all_months(
|
35
|
-
new_year_date: new_year_date, months: months
|
36
|
-
)
|
37
|
-
|
38
|
-
years[index] = Year.new(
|
39
|
-
multi_gengou: year.multi_gengou, new_year_date: new_year_date,
|
40
|
-
months: months, total_days: year.total_days
|
41
|
-
)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
#
|
46
|
-
# 全ての月で月初日の西暦日を更新する
|
47
|
-
#
|
48
|
-
# @param [Western::Calendar] new_year_date 元旦
|
49
|
-
# @param [Array<Month>] months 月データ
|
50
|
-
#
|
51
|
-
def self.update_first_day_within_all_months(new_year_date:, months:)
|
52
|
-
date = new_year_date.clone
|
53
|
-
months.each_with_index do |month, index|
|
54
|
-
updated_month = Month.new(
|
55
|
-
month_label: month.month_label,
|
56
|
-
first_day: FirstDay.new(remainder: month.first_day.remainder,
|
57
|
-
western_date: date),
|
58
|
-
solar_terms: month.solar_terms
|
59
|
-
)
|
60
|
-
months[index] = updated_month
|
61
|
-
|
62
|
-
date = date.clone + updated_month.days
|
63
|
-
end
|
64
|
-
end
|
65
|
-
private_class_method :update_first_day_within_all_months
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,138 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../base/multi_gengou_roller'
|
4
|
-
|
5
|
-
require_relative '../../../era/western'
|
6
|
-
require_relative './annual_range'
|
7
|
-
|
8
|
-
require_relative '../base/year'
|
9
|
-
|
10
|
-
# :nodoc:
|
11
|
-
module Zakuro
|
12
|
-
# :nodoc:
|
13
|
-
module Senmyou
|
14
|
-
#
|
15
|
-
# YearBoundary 年境界
|
16
|
-
#
|
17
|
-
module YearBoundary
|
18
|
-
#
|
19
|
-
# 年間範囲内の年データの開始月を変更する
|
20
|
-
#
|
21
|
-
# @param [Array<Year>] annual_ranges 年データ(冬至基準)
|
22
|
-
#
|
23
|
-
# @return [Array<Year>] 年データ(元旦基準)
|
24
|
-
#
|
25
|
-
def self.get(annual_ranges:)
|
26
|
-
categorize(annual_ranges: annual_ranges)
|
27
|
-
rearranged_years(annual_ranges: annual_ranges)
|
28
|
-
end
|
29
|
-
|
30
|
-
#
|
31
|
-
# 年間範囲内の年データの開始月を変更する
|
32
|
-
#
|
33
|
-
# @param [Array<Year>] annual_ranges 年データ(冬至基準)
|
34
|
-
#
|
35
|
-
# @return [Array<Year>] 年データ(元旦基準)
|
36
|
-
#
|
37
|
-
def self.rearranged_years(annual_ranges:)
|
38
|
-
years = []
|
39
|
-
|
40
|
-
(0..(annual_ranges.size - 2)).each do |index|
|
41
|
-
year = rearranged_year(annual_ranges: annual_ranges, index: index)
|
42
|
-
years.push(year)
|
43
|
-
end
|
44
|
-
|
45
|
-
years
|
46
|
-
end
|
47
|
-
private_class_method :rearranged_years
|
48
|
-
|
49
|
-
#
|
50
|
-
# 年間範囲を昨年/今年で分類する
|
51
|
-
#
|
52
|
-
# @param [Array<Year>] annual_range 1年データ
|
53
|
-
#
|
54
|
-
def self.categorize(annual_ranges:)
|
55
|
-
annual_ranges.each do |annual_range|
|
56
|
-
categorize_year(annual_range: annual_range)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
private_class_method :categorize
|
60
|
-
|
61
|
-
#
|
62
|
-
# 各月を昨年/今年で分類する
|
63
|
-
#
|
64
|
-
# @param [Array<Month>] annual_range 1年データ
|
65
|
-
#
|
66
|
-
def self.categorize_year(annual_range:)
|
67
|
-
is_last_year = true
|
68
|
-
annual_range.each_with_index do |month, index|
|
69
|
-
is_last_year = false if month.number == 1
|
70
|
-
|
71
|
-
annual_range[index] = InitializedMonth.new(
|
72
|
-
month_label: month.month_label, first_day: month.first_day,
|
73
|
-
solar_terms: month.solar_terms, phase_index: month.phase_index,
|
74
|
-
is_last_year: is_last_year
|
75
|
-
)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
private_class_method :categorize_year
|
79
|
-
|
80
|
-
#
|
81
|
-
# 年データの開始月を変更する
|
82
|
-
#
|
83
|
-
# @param [Array<Year>] annual_ranges 年データ(冬至基準)
|
84
|
-
# @param [Integer] index 対象年の要素番号
|
85
|
-
#
|
86
|
-
# @return [Year] 年データ(元旦基準)
|
87
|
-
#
|
88
|
-
def self.rearranged_year(annual_ranges:, index:)
|
89
|
-
current_annual_range = annual_ranges[index]
|
90
|
-
next_annual_range = annual_ranges[index + 1]
|
91
|
-
|
92
|
-
year = push_current_year(annual_range: current_annual_range)
|
93
|
-
push_last_year(annual_range: next_annual_range, year: year)
|
94
|
-
|
95
|
-
year
|
96
|
-
end
|
97
|
-
private_class_method :rearranged_year
|
98
|
-
|
99
|
-
#
|
100
|
-
# 当年データを生成する
|
101
|
-
#
|
102
|
-
# @param [Array<Year>] annual_ranges 年データ(冬至基準)
|
103
|
-
# @param [Year] year 対象年
|
104
|
-
#
|
105
|
-
# @return [Year] 当年月ありの対象年
|
106
|
-
#
|
107
|
-
def self.push_current_year(annual_range:, year: Year.new)
|
108
|
-
annual_range.each do |month|
|
109
|
-
next if month.is_last_year
|
110
|
-
|
111
|
-
year.push(month: month)
|
112
|
-
end
|
113
|
-
|
114
|
-
year
|
115
|
-
end
|
116
|
-
private_class_method :push_current_year
|
117
|
-
|
118
|
-
#
|
119
|
-
# 昨年データを生成する
|
120
|
-
#
|
121
|
-
# @param [Array<Year>] annual_ranges 年データ(冬至基準)
|
122
|
-
# @param [Year] year 対象年
|
123
|
-
#
|
124
|
-
# @return [Year] 昨年月ありの対象年
|
125
|
-
#
|
126
|
-
def self.push_last_year(annual_range:, year: Year.new)
|
127
|
-
annual_range.each do |month|
|
128
|
-
next unless month.is_last_year
|
129
|
-
|
130
|
-
year.push(month: month)
|
131
|
-
end
|
132
|
-
|
133
|
-
year
|
134
|
-
end
|
135
|
-
private_class_method :push_last_year
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../../era/western'
|
4
|
-
require_relative '../range/full_range'
|
5
|
-
require_relative '../base/multi_gengou_roller'
|
6
|
-
require_relative '../base/year'
|
7
|
-
require_relative '../../../output/response'
|
8
|
-
require_relative '../../../output/logger'
|
9
|
-
|
10
|
-
# :nodoc:
|
11
|
-
module Zakuro
|
12
|
-
# :nodoc:
|
13
|
-
module Senmyou
|
14
|
-
#
|
15
|
-
# SingleDaySpecifier 一日検索
|
16
|
-
#
|
17
|
-
module SingleDaySpecifier
|
18
|
-
# @return [Logger] ロガー
|
19
|
-
LOGGER = Logger.new(location: 'specifier')
|
20
|
-
|
21
|
-
#
|
22
|
-
# 取得する
|
23
|
-
#
|
24
|
-
# @param [Array<Year>] yeas 範囲
|
25
|
-
# @param [Western::Calendar] date 西暦日
|
26
|
-
#
|
27
|
-
# @return [Result::Data::SingleDay] 和暦日
|
28
|
-
#
|
29
|
-
def self.get(years: [], date: Western::Calendar.new)
|
30
|
-
year = specify_year(years: years, date: date)
|
31
|
-
|
32
|
-
year = transfer(year: year, date: date)
|
33
|
-
|
34
|
-
month = specify_month(year: year, date: date)
|
35
|
-
first_date = month.western_date
|
36
|
-
|
37
|
-
Response::SingleDay.save_single_day(
|
38
|
-
param: Response::SingleDay::Param.new(
|
39
|
-
year: year, month: month,
|
40
|
-
date: date, days: date - first_date
|
41
|
-
)
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
#
|
46
|
-
# 年を特定する
|
47
|
-
#
|
48
|
-
# @param [Array<Year>] years 範囲
|
49
|
-
# @param [Western::Calendar] date 西暦日
|
50
|
-
#
|
51
|
-
# @return [Year] 対象年
|
52
|
-
#
|
53
|
-
def self.specify_year(years:, date:)
|
54
|
-
years.reverse_each do |year|
|
55
|
-
return year if date >= year.new_year_date
|
56
|
-
end
|
57
|
-
|
58
|
-
raise ArgumentError, "invalid year range. date: #{date.format}"
|
59
|
-
end
|
60
|
-
private_class_method :specify_year
|
61
|
-
|
62
|
-
#
|
63
|
-
# 改元する
|
64
|
-
#
|
65
|
-
# @param [Year] year 年
|
66
|
-
# @param [Western::Calendar] date 西暦日
|
67
|
-
#
|
68
|
-
# @return [Year] 改元後の年
|
69
|
-
#
|
70
|
-
def self.transfer(year:, date:)
|
71
|
-
multi_gengou = MultiGengouRoller.transfer(multi_gengou: year.multi_gengou, date: date)
|
72
|
-
Year.new(multi_gengou: multi_gengou, new_year_date: year.new_year_date,
|
73
|
-
months: year.months, total_days: year.total_days)
|
74
|
-
end
|
75
|
-
private_class_method :transfer
|
76
|
-
|
77
|
-
# :reek:TooManyStatements { max_statements: 7 }
|
78
|
-
|
79
|
-
#
|
80
|
-
# 月を特定する
|
81
|
-
#
|
82
|
-
# @param [Year] year 年
|
83
|
-
# @param [Western::Calendar] date 西暦日
|
84
|
-
#
|
85
|
-
# @return [Month] 対象月
|
86
|
-
#
|
87
|
-
def self.specify_month(year:, date:)
|
88
|
-
months = year.months
|
89
|
-
|
90
|
-
current_month = months[0]
|
91
|
-
months.each do |month|
|
92
|
-
return current_month if month.western_date > date
|
93
|
-
|
94
|
-
current_month = month
|
95
|
-
end
|
96
|
-
|
97
|
-
current_month
|
98
|
-
end
|
99
|
-
private_class_method :specify_month
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.expand_path('../../../../../' \
|
4
|
-
'lib/zakuro/version/senmyou/specifier/single_day_specifier',
|
5
|
-
__dir__)
|
6
|
-
|
7
|
-
require File.expand_path('../../../../../' \
|
8
|
-
'lib/zakuro/version/senmyou/range/full_range',
|
9
|
-
__dir__)
|
10
|
-
|
11
|
-
require File.expand_path('../../../../../' \
|
12
|
-
'lib/zakuro/version/senmyou/range/operated_range',
|
13
|
-
__dir__)
|
14
|
-
|
15
|
-
# :nodoc:
|
16
|
-
module Zakuro
|
17
|
-
# :nodoc:
|
18
|
-
module Senmyou
|
19
|
-
#
|
20
|
-
# Single 一日
|
21
|
-
#
|
22
|
-
module Single
|
23
|
-
#
|
24
|
-
# 生成する
|
25
|
-
#
|
26
|
-
# @param [Western::Calendar] date 西暦日
|
27
|
-
#
|
28
|
-
# @return [Result::Single] 一日検索結果(和暦日)
|
29
|
-
#
|
30
|
-
def self.get(date: Western::Calendar.new)
|
31
|
-
full_range = FullRange.new(start_date: date)
|
32
|
-
years = full_range.get
|
33
|
-
|
34
|
-
calc_date = SingleDaySpecifier.get(years: years, date: date)
|
35
|
-
|
36
|
-
operated_range = OperatedRange.new(years: years)
|
37
|
-
|
38
|
-
Result::Single.new(
|
39
|
-
data: SingleDaySpecifier.get(years: operated_range.get, date: date),
|
40
|
-
operation: create_operation(calc_date: calc_date)
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# 運用情報を生成する
|
46
|
-
#
|
47
|
-
# @param [Result::Data::SingleDay] calc_date 和暦日(計算値)
|
48
|
-
#
|
49
|
-
# @return [Result::Operation::Bundle] 運用情報
|
50
|
-
#
|
51
|
-
def self.create_operation(calc_date: Result::Data::SingleDay.new)
|
52
|
-
first_day = calc_date.month.first_day.western_date
|
53
|
-
operation_history = Operation.specify_history(western_date: first_day)
|
54
|
-
|
55
|
-
operation_month = create_operation_month(operation_history: operation_history)
|
56
|
-
|
57
|
-
Result::Operation::Bundle.new(
|
58
|
-
operated: !operation_history.invalid?, month: operation_month, original: calc_date
|
59
|
-
)
|
60
|
-
end
|
61
|
-
private_class_method :create_operation
|
62
|
-
|
63
|
-
#
|
64
|
-
# 月履歴集約情報を生成する
|
65
|
-
#
|
66
|
-
# @param [Operation::MonthHistory] operation_history 変更履歴(月)
|
67
|
-
#
|
68
|
-
# @return [Result::Operation::Month::Bundle] 月履歴集約情報
|
69
|
-
#
|
70
|
-
def self.create_operation_month(operation_history: Operation::MonthHistory.new)
|
71
|
-
return Result::Operation::Month::Bundle.new if operation_history.invalid?
|
72
|
-
|
73
|
-
parent_operation_history = Operation.specify_history_by_id(id: operation_history.parent_id)
|
74
|
-
|
75
|
-
Result::Operation::Month::Bundle.new(
|
76
|
-
current: create_operation_month_history(operation_history: operation_history),
|
77
|
-
parent: create_operation_month_history(operation_history: parent_operation_history)
|
78
|
-
)
|
79
|
-
end
|
80
|
-
private_class_method :create_operation_month
|
81
|
-
|
82
|
-
#
|
83
|
-
# 月別履歴情報を生成する
|
84
|
-
#
|
85
|
-
# @param [Operation::MonthHistory] operation_history 変更履歴(月)
|
86
|
-
#
|
87
|
-
# @return [Result::Operation::Month::History] 月別履歴情報
|
88
|
-
#
|
89
|
-
def self.create_operation_month_history(operation_history: Operation::MonthHistory.new)
|
90
|
-
return Result::Operation::Month::History.new if operation_history.invalid?
|
91
|
-
|
92
|
-
annotations = create_annnotations(operation_history: operation_history)
|
93
|
-
|
94
|
-
reference = operation_history.reference
|
95
|
-
Result::Operation::Month::History.new(
|
96
|
-
id: operation_history.id, western_date: operation_history.western_date.format,
|
97
|
-
page: reference.page, number: reference.number, annotations: annotations
|
98
|
-
)
|
99
|
-
end
|
100
|
-
private_class_method :create_operation_month_history
|
101
|
-
|
102
|
-
#
|
103
|
-
# 注釈情報を生成する
|
104
|
-
#
|
105
|
-
# @param [Operation::MonthHistory] operation_history 変更履歴(月)
|
106
|
-
#
|
107
|
-
# @return [Array<Result::Operation::Month::Annotation>] 注釈
|
108
|
-
#
|
109
|
-
def self.create_annnotations(operation_history: Operation::MonthHistory.new)
|
110
|
-
annotations = []
|
111
|
-
operation_history.annotations.each do |annotation|
|
112
|
-
annotations.push(
|
113
|
-
Result::Operation::Month::Annotation.new(
|
114
|
-
description: annotation.description,
|
115
|
-
note: annotation.note
|
116
|
-
)
|
117
|
-
)
|
118
|
-
end
|
119
|
-
|
120
|
-
annotations
|
121
|
-
end
|
122
|
-
private_class_method :create_annnotations
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|