zakuro 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zakuro/operation/month/parser.rb +1 -1
- data/lib/zakuro/operation/month/type.rb +5 -10
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/senmyou/base/solar_term.rb +62 -0
- data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +71 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +2 -2
- data/lib/zakuro/version/senmyou/monthly/operated_month.rb +77 -48
- data/lib/zakuro/version/senmyou/range/annual_range.rb +17 -42
- data/lib/zakuro/version/senmyou/range/full_range.rb +8 -138
- data/lib/zakuro/version/senmyou/range/western_date_allocation.rb +68 -0
- data/lib/zakuro/version/senmyou/range/year_boundary.rb +138 -0
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +1 -1
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +101 -146
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +213 -0
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +1 -182
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd8b402a7084ab57e0424c65d9851cc72f759b81f6f9b4c7f1e71afcda27d561
|
4
|
+
data.tar.gz: f204f25a8a6addad96556cb9376b406d6c1285375e79c693169d3095b6f5b387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7c7c8b0fef50d3da9f45701883ec271f3c000676a4a70e1d0c73ae4b15249e6a2cd57be47bd01a9ad6109da9b6593745ccc348c83d32743a09442bf7a922343
|
7
|
+
data.tar.gz: c5e6aa6ef4b4cc21814859753bf8bfd02be637173011bc6a2eb3dd28f4cfe1505d9faeb6544759f3f92543a8ee35820c73d54811a48d9d47ab645d38a995ed16
|
@@ -340,7 +340,7 @@ module Zakuro
|
|
340
340
|
Month.new(
|
341
341
|
number: create_month_number(yaml_hash: yaml_hash['number']),
|
342
342
|
leaped: create_month_leaped(yaml_hash: yaml_hash['leaped']),
|
343
|
-
|
343
|
+
is_many_days: create_month_day(yaml_hash: yaml_hash['days'])
|
344
344
|
)
|
345
345
|
end
|
346
346
|
private_class_method :create_month
|
@@ -186,7 +186,7 @@ module Zakuro
|
|
186
186
|
# @return [Leaped] 閏有無
|
187
187
|
attr_reader :leaped
|
188
188
|
# @return [Days] 月の大小
|
189
|
-
attr_reader :
|
189
|
+
attr_reader :is_many_days
|
190
190
|
|
191
191
|
# :reek:BooleanParameter
|
192
192
|
|
@@ -197,10 +197,10 @@ module Zakuro
|
|
197
197
|
# @param [Leaped] leaped 閏有無
|
198
198
|
# @param [Days] days 月の大小
|
199
199
|
#
|
200
|
-
def initialize(number: Number.new, leaped: Leaped.new,
|
200
|
+
def initialize(number: Number.new, leaped: Leaped.new, is_many_days: Days.new)
|
201
201
|
@number = number
|
202
202
|
@leaped = leaped
|
203
|
-
@
|
203
|
+
@is_many_days = is_many_days
|
204
204
|
end
|
205
205
|
|
206
206
|
#
|
@@ -408,11 +408,6 @@ module Zakuro
|
|
408
408
|
# @return [String] 30日
|
409
409
|
BIG = '大'
|
410
410
|
|
411
|
-
# @return [String] 計算
|
412
|
-
attr_reader :calc
|
413
|
-
# @return [String] 運用
|
414
|
-
attr_reader :actual
|
415
|
-
|
416
411
|
#
|
417
412
|
# 初期化
|
418
413
|
#
|
@@ -430,7 +425,7 @@ module Zakuro
|
|
430
425
|
# @return [True] 大
|
431
426
|
# @return [False] 小
|
432
427
|
#
|
433
|
-
def
|
428
|
+
def calc
|
434
429
|
@calc == BIG
|
435
430
|
end
|
436
431
|
|
@@ -440,7 +435,7 @@ module Zakuro
|
|
440
435
|
# @return [True] 大
|
441
436
|
# @return [False] 小
|
442
437
|
#
|
443
|
-
def
|
438
|
+
def actual
|
444
439
|
@actual == BIG
|
445
440
|
end
|
446
441
|
|
data/lib/zakuro/version.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
|
4
|
+
require_relative './remainder'
|
5
|
+
|
3
6
|
# :nodoc:
|
4
7
|
module Zakuro
|
5
8
|
# :nodoc:
|
@@ -13,6 +16,9 @@ module Zakuro
|
|
13
16
|
# @return [Remainder] 時刻情報(大余小余)
|
14
17
|
attr_reader :remainder
|
15
18
|
|
19
|
+
# @return [Remainder] 気策(24分の1年)
|
20
|
+
SOLAR_TERM_AVERAGE = Remainder.new(day: 15, minute: 1835, second: 5)
|
21
|
+
|
16
22
|
# @return [Hash<Integer, Symbol>] 順序
|
17
23
|
ORDER = {
|
18
24
|
0 => :touji,
|
@@ -72,6 +78,62 @@ module Zakuro
|
|
72
78
|
(@index == -1 && @remainder.invalid?)
|
73
79
|
end
|
74
80
|
|
81
|
+
def index?(index)
|
82
|
+
result = ORDER.fetch(index, -1)
|
83
|
+
|
84
|
+
result != -1
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# 次の二十四節気に進める
|
89
|
+
#
|
90
|
+
def next!
|
91
|
+
@index += 1
|
92
|
+
@index = 0 if @index >= ORDER.size
|
93
|
+
|
94
|
+
@remainder.add!(SOLAR_TERM_AVERAGE)
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# 指定した連番の二十四節気まで進める
|
99
|
+
#
|
100
|
+
# @param [Integer] index 連番
|
101
|
+
#
|
102
|
+
def next_by_index(index)
|
103
|
+
return ArgumentError.new, 'invalid index' unless index?(index)
|
104
|
+
|
105
|
+
loop do
|
106
|
+
return if @index == index
|
107
|
+
|
108
|
+
next!
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# 指定した連番の二十四節気まで戻す
|
114
|
+
#
|
115
|
+
# @param [Integer] index 連番
|
116
|
+
#
|
117
|
+
def prev_by_index(index)
|
118
|
+
return ArgumentError.new, 'invalid index' unless index?(index)
|
119
|
+
|
120
|
+
loop do
|
121
|
+
return if @index == index
|
122
|
+
|
123
|
+
prev!
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
#
|
128
|
+
# 前の二十四節気に戻る
|
129
|
+
#
|
130
|
+
def prev!
|
131
|
+
@index -= 1
|
132
|
+
@index = 23 if @index.negative?
|
133
|
+
|
134
|
+
@remainder.sub!(SOLAR_TERM_AVERAGE)
|
135
|
+
end
|
136
|
+
|
75
137
|
#
|
76
138
|
# ディープコピー
|
77
139
|
#
|
@@ -37,12 +37,83 @@ module Zakuro
|
|
37
37
|
@phase_index = phase_index
|
38
38
|
end
|
39
39
|
|
40
|
+
# :reek:TooManyStatements { max_statements: 6 }
|
41
|
+
|
42
|
+
#
|
43
|
+
# 現在の二十四節気に合わせて月表示情報を書き換える
|
44
|
+
#
|
45
|
+
def rename_month_label_by_solar_term
|
46
|
+
return ArgumentError.new, 'solar term must not be empty.' if empty_solar_term?
|
47
|
+
|
48
|
+
even = even_term
|
49
|
+
|
50
|
+
is_many_days = month_label.is_many_days
|
51
|
+
if even.invalid?
|
52
|
+
@month_label = MonthLabel.new(
|
53
|
+
number: InitializedMonth.month_number_by_odd_term_index(odd_term.index),
|
54
|
+
leaped: true, is_many_days: is_many_days
|
55
|
+
)
|
56
|
+
return
|
57
|
+
end
|
58
|
+
|
59
|
+
@month_label = MonthLabel.new(
|
60
|
+
number: InitializedMonth.month_number_by_even_term_index(even.index),
|
61
|
+
leaped: false, is_many_days: is_many_days
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# 中気の連番に合わせて月を返す
|
67
|
+
#
|
68
|
+
# @example
|
69
|
+
# 20: 9月
|
70
|
+
# 22: 10月
|
71
|
+
# 0: 11月
|
72
|
+
# 2: 12月
|
73
|
+
# 4: 1月
|
74
|
+
#
|
75
|
+
# @param [Integer] index 中気番号
|
76
|
+
#
|
77
|
+
# @return [Integer] 月
|
78
|
+
#
|
79
|
+
def self.month_number_by_even_term_index(index)
|
80
|
+
half_index = index / 2
|
81
|
+
|
82
|
+
# 11月、12月
|
83
|
+
return half_index + 11 if half_index < 2
|
84
|
+
|
85
|
+
# 1月~10月
|
86
|
+
half_index - 1
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# 節気の連番に合わせて月を返す
|
91
|
+
#
|
92
|
+
# @param [Integer] index 節気番号
|
93
|
+
#
|
94
|
+
# @return [Integer] 月
|
95
|
+
#
|
96
|
+
def self.month_number_by_odd_term_index(index)
|
97
|
+
even_index = index - 1
|
98
|
+
|
99
|
+
month_number_by_even_term_index(even_index)
|
100
|
+
end
|
101
|
+
|
40
102
|
#
|
41
103
|
# 一ヶ月戻す
|
42
104
|
#
|
43
105
|
def back_to_last_month
|
44
106
|
@is_last_year = true if month_label.back_to_last_month
|
45
107
|
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# 二十四節気の数を返す
|
111
|
+
#
|
112
|
+
# @return [Integer] 二十四節気の数
|
113
|
+
#
|
114
|
+
def solar_term_size
|
115
|
+
solar_terms.size
|
116
|
+
end
|
46
117
|
end
|
47
118
|
end
|
48
119
|
end
|
@@ -59,7 +59,7 @@ module Zakuro
|
|
59
59
|
@average_remainder = WinterSolstice.calc_averaged_last_november_1st(
|
60
60
|
western_year: @western_year
|
61
61
|
)
|
62
|
-
#
|
62
|
+
# 天正閏余
|
63
63
|
winter_solstice_age = \
|
64
64
|
WinterSolstice.calc_moon_age(western_year: @western_year)
|
65
65
|
# 入定気
|
@@ -180,7 +180,7 @@ module Zakuro
|
|
180
180
|
# @return [Integer] 太陽運動の補正値
|
181
181
|
#
|
182
182
|
def correction_solar_value
|
183
|
-
@solar_term =
|
183
|
+
@solar_term = SolarLocation.get(
|
184
184
|
solar_term: @solar_term
|
185
185
|
)
|
186
186
|
debug("@solar_term.remainder: #{@solar_term.remainder.format(form: '%d-%d.%d')}")
|
@@ -7,6 +7,8 @@ require_relative '../../../operation/operation'
|
|
7
7
|
module Zakuro
|
8
8
|
# :nodoc:
|
9
9
|
module Senmyou
|
10
|
+
# :reek:TooManyInstanceVariables { max_instance_variables: 5 }
|
11
|
+
|
10
12
|
#
|
11
13
|
# OperatedMonth 月情報(運用)
|
12
14
|
#
|
@@ -19,13 +21,14 @@ module Zakuro
|
|
19
21
|
#
|
20
22
|
# 初期化
|
21
23
|
#
|
24
|
+
# @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
|
22
25
|
# @param [MonthLabel] month_label 月表示名
|
23
26
|
# @param [FirstDay] first_day 月初日(朔日)
|
24
27
|
# @param [Array<SolarTerm>] solar_terms 二十四節気
|
25
28
|
# @param [Operation::MonthHistory] history 変更履歴(月)
|
26
29
|
#
|
27
|
-
def initialize(operated_solar_terms:, month_label: MonthLabel.new, first_day: FirstDay.new,
|
28
|
-
history: Operation::MonthHistory.new)
|
30
|
+
def initialize(operated_solar_terms:, month_label: MonthLabel.new, first_day: FirstDay.new,
|
31
|
+
solar_terms: [], history: Operation::MonthHistory.new)
|
29
32
|
super(month_label: month_label, first_day: first_day, solar_terms: solar_terms)
|
30
33
|
@history = history
|
31
34
|
@operated_solar_terms = operated_solar_terms
|
@@ -47,77 +50,103 @@ module Zakuro
|
|
47
50
|
diff = history.diffs.month
|
48
51
|
|
49
52
|
@month_label = MonthLabel.new(
|
50
|
-
number:
|
51
|
-
|
52
|
-
|
53
|
+
number: OperatedMonth.rewrite_month_fields(
|
54
|
+
month_diff: diff, month_label: month_label, name: 'number'
|
55
|
+
),
|
56
|
+
is_many_days: OperatedMonth.rewrite_month_fields(
|
57
|
+
month_diff: diff, month_label: month_label, name: 'is_many_days'
|
58
|
+
),
|
59
|
+
leaped: OperatedMonth.rewrite_month_fields(
|
60
|
+
month_diff: diff, month_label: month_label, name: 'leaped'
|
61
|
+
)
|
53
62
|
)
|
54
63
|
end
|
55
64
|
|
65
|
+
def self.rewrite_month_fields(month_diff:, month_label:, name:)
|
66
|
+
method_name = name.intern
|
67
|
+
|
68
|
+
diff = month_diff.send(method_name)
|
69
|
+
default = month_label.send(method_name)
|
70
|
+
return default if diff.invalid?
|
71
|
+
|
72
|
+
diff.actual
|
73
|
+
end
|
74
|
+
|
56
75
|
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# @param [Operation::Number] diff 差分
|
60
|
-
#
|
61
|
-
# @return [Integer] 月
|
76
|
+
# 二十四節気ごとの差分で書き換える
|
62
77
|
#
|
63
|
-
def
|
64
|
-
|
78
|
+
def rewrite_solar_terms
|
79
|
+
matched, operated_solar_term = @operated_solar_terms.get(
|
80
|
+
western_date: first_day.western_date
|
81
|
+
)
|
65
82
|
|
66
|
-
|
83
|
+
return unless matched
|
84
|
+
|
85
|
+
@solar_terms = OperatedMonth.create_operated_solar_terms(
|
86
|
+
operated_solar_term: operated_solar_term,
|
87
|
+
solar_terms: solar_terms
|
88
|
+
)
|
67
89
|
end
|
68
90
|
|
69
91
|
#
|
70
|
-
#
|
92
|
+
# <Description>
|
71
93
|
#
|
72
|
-
# @param [
|
94
|
+
# @param [<Type>] operated_solar_term <description>
|
95
|
+
# @param [Array<SolarTerm>] solar_terms 二十四節気
|
73
96
|
#
|
74
|
-
# @return [
|
97
|
+
# @return [Array<SolarTerm>] 二十四節気
|
75
98
|
#
|
76
|
-
def
|
77
|
-
|
99
|
+
def self.create_operated_solar_terms(operated_solar_term:, solar_terms:)
|
100
|
+
index = operated_solar_term.index
|
101
|
+
|
102
|
+
# 別の月に移動する二十四節気。割り当てない。
|
103
|
+
result = remove_solar_term(index: index, solar_terms: solar_terms)
|
78
104
|
|
79
|
-
|
105
|
+
return result if used_solar_term?(index: index, solar_terms: solar_terms)
|
106
|
+
|
107
|
+
result.push(operated_solar_term)
|
108
|
+
|
109
|
+
result
|
80
110
|
end
|
81
111
|
|
112
|
+
# :reek:ControlParameter
|
113
|
+
|
82
114
|
#
|
83
|
-
#
|
115
|
+
# 二十四節気が使用されているか
|
84
116
|
#
|
85
|
-
# @param [
|
117
|
+
# @param [Integer] index 二十四節気番号
|
118
|
+
# @param [Array<SolarTerm>] solar_terms 二十四節気
|
86
119
|
#
|
87
|
-
# @return [True]
|
88
|
-
# @return [False]
|
120
|
+
# @return [True] 使用
|
121
|
+
# @return [False] 未使用
|
89
122
|
#
|
90
|
-
def
|
91
|
-
|
123
|
+
def self.used_solar_term?(index:, solar_terms:)
|
124
|
+
solar_terms.each do |solar_term|
|
125
|
+
return true if index == solar_term.index
|
126
|
+
end
|
92
127
|
|
93
|
-
|
128
|
+
false
|
94
129
|
end
|
95
130
|
|
131
|
+
# :reek:ControlParameter
|
132
|
+
|
96
133
|
#
|
97
|
-
#
|
134
|
+
# 対象の二十四節気を除外する
|
98
135
|
#
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
used = false
|
109
|
-
@solar_terms.each do |solar_term|
|
110
|
-
if operated_solar_term.index == solar_term.index
|
111
|
-
used = true
|
112
|
-
next
|
113
|
-
end
|
136
|
+
# @param [Integer] index 二十四節気番号
|
137
|
+
# @param [Array<SolarTerm>] solar_terms 二十四節気
|
138
|
+
#
|
139
|
+
# @return [Array<SolarTerm>] 二十四節気(対象除外済)
|
140
|
+
#
|
141
|
+
def self.remove_solar_term(index:, solar_terms:)
|
142
|
+
result = []
|
143
|
+
solar_terms.each do |solar_term|
|
144
|
+
next if index == solar_term.index
|
114
145
|
|
115
|
-
|
146
|
+
result.push(solar_term)
|
116
147
|
end
|
117
148
|
|
118
|
-
|
119
|
-
|
120
|
-
@solar_terms = operated_solar_terms
|
149
|
+
result
|
121
150
|
end
|
122
151
|
|
123
152
|
#
|
@@ -143,7 +172,7 @@ module Zakuro
|
|
143
172
|
# @return [Remainder] 月初日の大余小余
|
144
173
|
#
|
145
174
|
def rewrite_remainder(days:)
|
146
|
-
remainder =
|
175
|
+
remainder = first_day.remainder.clone
|
147
176
|
remainder.add!(Remainder.new(day: days, minute: 0, second: 0))
|
148
177
|
|
149
178
|
remainder
|
@@ -157,7 +186,7 @@ module Zakuro
|
|
157
186
|
# @return [Western::Calendar] 月初日の西暦日
|
158
187
|
#
|
159
188
|
def rewrite_western_date(days:)
|
160
|
-
western_date =
|
189
|
+
western_date = first_day.western_date.clone
|
161
190
|
western_date += days
|
162
191
|
|
163
192
|
western_date
|