zakuro 0.1.2 → 0.3.0
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 +484 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
- data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +169 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
- data/lib/zakuro/calculation/monthly/month.rb +187 -0
- data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
- data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
- data/lib/zakuro/calculation/range/full_range.rb +210 -0
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +105 -0
- data/lib/zakuro/calculation/range/operated_range.rb +144 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +78 -0
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +71 -0
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +117 -0
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +187 -0
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +136 -0
- data/lib/zakuro/calculation/summary/single.rb +129 -0
- data/lib/zakuro/calculation/type/old_float.rb +69 -0
- data/lib/zakuro/era/japan/reki.rb +1 -1
- 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/daien/const/number.rb +55 -0
- data/lib/zakuro/version/daien/const/remainder.rb +53 -0
- data/lib/zakuro/version/daien/cycle/remainder.rb +59 -0
- data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/daien/daien.rb +36 -0
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
- data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
- data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
- data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
- data/lib/zakuro/version/gihou/const/number.rb +55 -0
- data/lib/zakuro/version/gihou/const/remainder.rb +54 -0
- data/lib/zakuro/version/gihou/cycle/remainder.rb +56 -0
- data/lib/zakuro/version/gihou/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/gihou/gihou.rb +23 -2
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +106 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +39 -0
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +250 -0
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/gihou/stella/lunar/location.rb +80 -0
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +75 -0
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/gihou/stella/solar/average.rb +97 -0
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +108 -0
- data/lib/zakuro/version/gihou/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/gihou/stella/solar/value.rb +36 -0
- data/lib/zakuro/version/senmyou/const/number.rb +51 -0
- data/lib/zakuro/version/senmyou/const/remainder.rb +47 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +56 -0
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +80 -195
- data/lib/zakuro/version/senmyou/range/annual_range.rb +25 -145
- data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +87 -0
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +67 -0
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +97 -0
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
- data/lib/zakuro/version/senmyou/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +39 -0
- data/lib/zakuro/version/version_class_resolver.rb +70 -0
- data/lib/zakuro/version_factory.rb +3 -3
- metadata +83 -28
- 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/stella/lunar_orbit.rb +0 -332
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -169
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +0 -213
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -213
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
- data/lib/zakuro/version/senmyou/summary/single.rb +0 -125
- data/lib/zakuro/version/taien/taien.rb +0 -19
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'date'
|
4
|
-
require_relative '../abstract_version'
|
5
4
|
require_relative '../../era/western'
|
6
|
-
require_relative '
|
5
|
+
require_relative '../abstract_version'
|
6
|
+
require_relative '../context'
|
7
|
+
require_relative '../../calculation/summary/single'
|
7
8
|
|
8
9
|
# :nodoc:
|
9
10
|
module Zakuro
|
@@ -18,16 +19,21 @@ module Zakuro
|
|
18
19
|
# @return [True] リリースあり
|
19
20
|
RELEASE = true
|
20
21
|
|
22
|
+
# @return [String] 暦クラス名
|
23
|
+
VERSION_NAME = 'Senmyou'
|
24
|
+
|
21
25
|
#
|
22
26
|
# 西暦日から和暦日に変換する
|
23
27
|
#
|
24
28
|
# @param [Date] western_date 西暦日
|
25
29
|
#
|
26
|
-
# @return [Result::
|
30
|
+
# @return [Result::Single] 和暦日
|
27
31
|
#
|
28
32
|
def self.to_japan_date(western_date:)
|
29
33
|
date = Western::Calendar.create(date: western_date)
|
30
|
-
|
34
|
+
|
35
|
+
context = Context.new(version_name: VERSION_NAME)
|
36
|
+
Calculation::Summary::Single.get(context: context, date: date)
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../const/number'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Senmyou
|
9
|
+
# :nodoc:
|
10
|
+
module Lunar
|
11
|
+
#
|
12
|
+
# Adjustment 補正値情報
|
13
|
+
#
|
14
|
+
module Adjustment
|
15
|
+
# @return [Integer] 遠/近の地点での中間
|
16
|
+
HALF_DAYS = [7].freeze
|
17
|
+
|
18
|
+
#
|
19
|
+
# Row 行情報
|
20
|
+
#
|
21
|
+
class Row
|
22
|
+
# @return [True] 進(遠地点より数える)
|
23
|
+
# @return [False] 退(近地点より数える)
|
24
|
+
attr_reader :forward
|
25
|
+
# @return [Integer] 入暦(1-14)
|
26
|
+
attr_reader :day
|
27
|
+
# @return [Range] 小余範囲
|
28
|
+
attr_reader :range
|
29
|
+
# @return [Value] 補正値
|
30
|
+
attr_reader :value
|
31
|
+
|
32
|
+
#
|
33
|
+
# 初期化
|
34
|
+
#
|
35
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
36
|
+
# @param [Integer] day 入暦(1-14)
|
37
|
+
# @param [Range] range 小余範囲
|
38
|
+
# @param [Value] value 補正値
|
39
|
+
#
|
40
|
+
def initialize(forward:, day:, range:, value:)
|
41
|
+
@forward = forward
|
42
|
+
@day = day
|
43
|
+
@range = range
|
44
|
+
@value = value
|
45
|
+
end
|
46
|
+
|
47
|
+
# :reek:ControlParameter
|
48
|
+
|
49
|
+
#
|
50
|
+
# 一致するか
|
51
|
+
#
|
52
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
53
|
+
# @param [Integer] day 入暦(1-14)
|
54
|
+
# @param [Integer] minute 小余
|
55
|
+
#
|
56
|
+
# @return [True] 一致
|
57
|
+
# @return [False] 不一致
|
58
|
+
#
|
59
|
+
def match?(forward:, day:, minute:)
|
60
|
+
return false unless @forward == forward
|
61
|
+
|
62
|
+
return false unless @day == day
|
63
|
+
|
64
|
+
return false unless @range.include?(minute: minute)
|
65
|
+
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# 分母を返す
|
71
|
+
#
|
72
|
+
# @return [Integer] 分母
|
73
|
+
#
|
74
|
+
def denominator
|
75
|
+
@range.denominator
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Range 小余範囲
|
81
|
+
#
|
82
|
+
class Range
|
83
|
+
# @return [Integer] 下限
|
84
|
+
MIN = 0
|
85
|
+
# @return [Integer] 上限
|
86
|
+
MAX = Const::Number::Cycle::DAY
|
87
|
+
# @return [Integer] 遠/近の地点での中間
|
88
|
+
HALF = 7465
|
89
|
+
# @return [Integer] 各地点の最後
|
90
|
+
LAST = 6529
|
91
|
+
|
92
|
+
# @return [Integer] 下限
|
93
|
+
attr_reader :min
|
94
|
+
# @return [Integer] 上限
|
95
|
+
attr_reader :max
|
96
|
+
|
97
|
+
#
|
98
|
+
# 初期化
|
99
|
+
#
|
100
|
+
# @param [Integer] min 下限
|
101
|
+
# @param [Integer] max 上限
|
102
|
+
#
|
103
|
+
def initialize(min: MIN, max: MAX)
|
104
|
+
@min = min
|
105
|
+
@max = max
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# 含まれるか
|
110
|
+
#
|
111
|
+
# @param [Integer] minute 小余
|
112
|
+
#
|
113
|
+
# @return [True] 含まれる
|
114
|
+
# @return [False] 含まれない
|
115
|
+
#
|
116
|
+
def include?(minute:)
|
117
|
+
minute >= @min && minute <= @max
|
118
|
+
end
|
119
|
+
|
120
|
+
#
|
121
|
+
# 分母を返す
|
122
|
+
#
|
123
|
+
# @return [Integer] 分母
|
124
|
+
#
|
125
|
+
def denominator
|
126
|
+
@max - @min
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Value 補正値
|
132
|
+
#
|
133
|
+
class Value
|
134
|
+
# @return [Integer] 損益率
|
135
|
+
attr_reader :per
|
136
|
+
# @return [Integer] 眺朒(ちょうじく)積
|
137
|
+
attr_reader :stack
|
138
|
+
|
139
|
+
#
|
140
|
+
# 初期化
|
141
|
+
#
|
142
|
+
# @param [Integer] per 損益率
|
143
|
+
# @param [Integer] stack 眺朒(ちょうじく)積
|
144
|
+
#
|
145
|
+
def initialize(per:, stack:)
|
146
|
+
@per = per
|
147
|
+
@stack = stack
|
148
|
+
end
|
149
|
+
|
150
|
+
#
|
151
|
+
# 文字化
|
152
|
+
#
|
153
|
+
# @return [String] 文字
|
154
|
+
#
|
155
|
+
def to_s
|
156
|
+
"per:#{@per}, stack:#{@stack}"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# rubocop:disable Layout/LineLength
|
161
|
+
|
162
|
+
#
|
163
|
+
# @return [Array<Row>] 月の補正値情報
|
164
|
+
#
|
165
|
+
LIST = [
|
166
|
+
Row.new(forward: true, day: 1, range: Range.new, value: Value.new(per: +830, stack: 0)),
|
167
|
+
Row.new(forward: true, day: 2, range: Range.new, value: Value.new(per: +726, stack: +830)),
|
168
|
+
Row.new(forward: true, day: 3, range: Range.new, value: Value.new(per: +606, stack: +1556)),
|
169
|
+
Row.new(forward: true, day: 4, range: Range.new, value: Value.new(per: +471, stack: +2162)),
|
170
|
+
Row.new(forward: true, day: 5, range: Range.new, value: Value.new(per: +337, stack: +2633)),
|
171
|
+
Row.new(forward: true, day: 6, range: Range.new, value: Value.new(per: +202, stack: +2970)),
|
172
|
+
Row.new(forward: true, day: 7, range: Range.new(max: Range::HALF), value: Value.new(per: +53, stack: +3172)),
|
173
|
+
Row.new(forward: true, day: 7, range: Range.new(min: Range::HALF), value: Value.new(per: -7, stack: +3225)), # +3172 + 53(初益)
|
174
|
+
Row.new(forward: true, day: 8, range: Range.new, value: Value.new(per: -82, stack: +3218)),
|
175
|
+
Row.new(forward: true, day: 9, range: Range.new, value: Value.new(per: -224, stack: +3136)),
|
176
|
+
Row.new(forward: true, day: 10, range: Range.new, value: Value.new(per: -366, stack: +2912)),
|
177
|
+
Row.new(forward: true, day: 11, range: Range.new, value: Value.new(per: -509, stack: +2546)),
|
178
|
+
Row.new(forward: true, day: 12, range: Range.new, value: Value.new(per: -643, stack: +2037)),
|
179
|
+
Row.new(forward: true, day: 13, range: Range.new, value: Value.new(per: -748, stack: +1394)),
|
180
|
+
Row.new(forward: true, day: 14, range: Range.new(max: Range::LAST), value: Value.new(per: -646, stack: +646)), # 14日の小余は常に6529以下
|
181
|
+
Row.new(forward: false, day: 1, range: Range.new, value: Value.new(per: -830, stack: 0)),
|
182
|
+
Row.new(forward: false, day: 2, range: Range.new, value: Value.new(per: -726, stack: -830)),
|
183
|
+
Row.new(forward: false, day: 3, range: Range.new, value: Value.new(per: -598, stack: -1556)),
|
184
|
+
Row.new(forward: false, day: 4, range: Range.new, value: Value.new(per: -464, stack: -2154)),
|
185
|
+
Row.new(forward: false, day: 5, range: Range.new, value: Value.new(per: -329, stack: -2618)),
|
186
|
+
Row.new(forward: false, day: 6, range: Range.new, value: Value.new(per: -195, stack: -2947)),
|
187
|
+
Row.new(forward: false, day: 7, range: Range.new(max: Range::HALF), value: Value.new(per: -53, stack: -3142)),
|
188
|
+
Row.new(forward: false, day: 7, range: Range.new(min: Range::HALF), value: Value.new(per: +7, stack: -3195)), # -3142 - 53(初益)
|
189
|
+
Row.new(forward: false, day: 8, range: Range.new, value: Value.new(per: +82, stack: -3188)),
|
190
|
+
Row.new(forward: false, day: 9, range: Range.new, value: Value.new(per: +225, stack: -3106)),
|
191
|
+
Row.new(forward: false, day: 10, range: Range.new, value: Value.new(per: +366, stack: -2881)),
|
192
|
+
Row.new(forward: false, day: 11, range: Range.new, value: Value.new(per: +501, stack: -2515)),
|
193
|
+
Row.new(forward: false, day: 12, range: Range.new, value: Value.new(per: +628, stack: -2014)),
|
194
|
+
Row.new(forward: false, day: 13, range: Range.new, value: Value.new(per: +740, stack: -1386)),
|
195
|
+
Row.new(forward: false, day: 14, range: Range.new(max: Range::LAST), value: Value.new(per: +646, stack: -646)) # 14日の小余は常に6529以下
|
196
|
+
].freeze
|
197
|
+
# rubocop:enable Layout/LineLength
|
198
|
+
|
199
|
+
#
|
200
|
+
# 月軌道の補正に必要な基本値を引き当てる
|
201
|
+
#
|
202
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
203
|
+
# @param [Integer] day 大余
|
204
|
+
# @param [Integer] minute 小余
|
205
|
+
#
|
206
|
+
# @return [Row] 補正値
|
207
|
+
#
|
208
|
+
def self.specify(forward:, day:, minute:)
|
209
|
+
LIST.each do |row|
|
210
|
+
# NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
|
211
|
+
return row if row.match?(forward: forward, day: day, minute: minute)
|
212
|
+
end
|
213
|
+
|
214
|
+
raise ArgumentError.new, "invalid parameter: #{forward}/#{day}/#{minute}"
|
215
|
+
end
|
216
|
+
|
217
|
+
# :reek:ControlParameter
|
218
|
+
|
219
|
+
#
|
220
|
+
# 小余の下げ幅を求める
|
221
|
+
#
|
222
|
+
# @param [Integer] day 大余
|
223
|
+
# @param [Integer] minute 小余
|
224
|
+
#
|
225
|
+
# @return [Integer] 小余の下げ幅
|
226
|
+
#
|
227
|
+
def self.minus_minute(day:, minute:)
|
228
|
+
return minute unless HALF_DAYS.include?(day)
|
229
|
+
|
230
|
+
return minute unless minute > Range::HALF
|
231
|
+
|
232
|
+
minute - Range::HALF
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../const/number'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Senmyou
|
9
|
+
# :nodoc:
|
10
|
+
module Lunar
|
11
|
+
#
|
12
|
+
# Localization 入暦特定
|
13
|
+
#
|
14
|
+
module Localization
|
15
|
+
# @return [Integer] 1近点月
|
16
|
+
ANOMALISTIC_MONTH = Const::Number::Cycle::ANOMALISTIC_MONTH
|
17
|
+
# @return [Integer] 積年
|
18
|
+
TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
|
19
|
+
# @return [Integer] 開始年
|
20
|
+
BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
|
21
|
+
# @return [Integer] 年
|
22
|
+
YEAR = Const::Number::Cycle::YEAR
|
23
|
+
|
24
|
+
#
|
25
|
+
# 対象年の最初の入暦を求める
|
26
|
+
#
|
27
|
+
# @param [Remainder] lunar_age 天正閏余
|
28
|
+
# @param [Integer] western_year 西暦年
|
29
|
+
#
|
30
|
+
# @return [Cycle::LunarRemainder] 入暦
|
31
|
+
#
|
32
|
+
def self.first_remainder(lunar_age:, western_year:)
|
33
|
+
# 積年の開始から対象年までの年数
|
34
|
+
total_year = TOTAL_YEAR + western_year - BEGIN_YEAR
|
35
|
+
|
36
|
+
# 通積分 - 天正閏余
|
37
|
+
total_day = total_year * YEAR - lunar_age.to_minute
|
38
|
+
|
39
|
+
Cycle::LunarRemainder.new(total: (total_day % ANOMALISTIC_MONTH))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../calculation/stella/lunar/abstract_location'
|
4
|
+
|
5
|
+
require_relative '../../const/remainder'
|
6
|
+
|
7
|
+
require_relative './localization'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Senmyou
|
13
|
+
# :nodoc:
|
14
|
+
module Lunar
|
15
|
+
#
|
16
|
+
# Location 入暦
|
17
|
+
#
|
18
|
+
class Location < Calculation::Lunar::AbstractLocation
|
19
|
+
# @return [Cycle::LunarRemainder] 暦中日(1近点月の半分)
|
20
|
+
HALF_ANOMALISTIC_MONTH = Const::Remainder::Lunar::HALF_ANOMALISTIC_MONTH
|
21
|
+
# @return [Cycle::LunarRemainder] 弦
|
22
|
+
QUARTER = Const::Remainder::Lunar::QUARTER
|
23
|
+
|
24
|
+
# @return [True] 進
|
25
|
+
# @return [False] 退
|
26
|
+
attr_reader :forward
|
27
|
+
|
28
|
+
#
|
29
|
+
# 初期化
|
30
|
+
#
|
31
|
+
# @param [Cycle::LunarRemainder] lunar_age 天正閏余(大余小余)
|
32
|
+
# @param [Integer] western_year 西暦年
|
33
|
+
#
|
34
|
+
def initialize(lunar_age:, western_year:)
|
35
|
+
super(lunar_age: lunar_age, western_year: western_year)
|
36
|
+
# 進
|
37
|
+
@forward = true
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# 入暦を計算する
|
42
|
+
#
|
43
|
+
def run
|
44
|
+
if calculated
|
45
|
+
decrease(limit: HALF_ANOMALISTIC_MONTH)
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
49
|
+
first
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# 弦の分だけ月地点を進める
|
54
|
+
#
|
55
|
+
def add_quarter
|
56
|
+
remainder.add!(QUARTER)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
#
|
62
|
+
# 初回計算
|
63
|
+
#
|
64
|
+
def first
|
65
|
+
@remainder = Localization.first_remainder(
|
66
|
+
lunar_age: remainder, western_year: western_year
|
67
|
+
)
|
68
|
+
decrease(limit: HALF_ANOMALISTIC_MONTH)
|
69
|
+
|
70
|
+
@calculated = true
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# 大余小余に合わせて減算する(折り返す)
|
75
|
+
#
|
76
|
+
# @param [Cycle::LunarRemainder] limit 上限
|
77
|
+
#
|
78
|
+
def decrease(limit:)
|
79
|
+
return if remainder < limit
|
80
|
+
|
81
|
+
remainder.sub!(limit)
|
82
|
+
@forward = !forward
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../calculation/stella/lunar/choukei_value'
|
4
|
+
|
5
|
+
require_relative '../../cycle/remainder'
|
6
|
+
|
7
|
+
require_relative './adjustment'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
# :nodoc:
|
12
|
+
module Senmyou
|
13
|
+
# :nodoc:
|
14
|
+
module Lunar
|
15
|
+
#
|
16
|
+
# Value 月補正値
|
17
|
+
#
|
18
|
+
module Value
|
19
|
+
# :reek:TooManyStatements { max_statements: 9 }
|
20
|
+
|
21
|
+
#
|
22
|
+
# 月の運行による補正値を算出する
|
23
|
+
#
|
24
|
+
# @param [Cycle::LunarRemainder] remainder 月の大余小余
|
25
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
26
|
+
#
|
27
|
+
# @return [Integer] 補正値
|
28
|
+
#
|
29
|
+
def self.get(remainder:, forward:)
|
30
|
+
valid?(remainder: remainder)
|
31
|
+
|
32
|
+
day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
|
33
|
+
remainder: remainder
|
34
|
+
)
|
35
|
+
|
36
|
+
# 引き当て
|
37
|
+
row = Adjustment.specify(forward: forward, day: day, minute: minute)
|
38
|
+
|
39
|
+
value = row.value
|
40
|
+
|
41
|
+
minus_minute = Adjustment.minus_minute(day: day, minute: minute)
|
42
|
+
|
43
|
+
day = Calculation::Lunar::ChoukeiValue.rounded_day(
|
44
|
+
per: value.per, denominator: row.denominator, minute: minus_minute
|
45
|
+
)
|
46
|
+
|
47
|
+
value.stack + day
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# 大余小余を検証する
|
52
|
+
#
|
53
|
+
# @param [Cycle::LunarRemainder] remainder 大余小余
|
54
|
+
#
|
55
|
+
# @return [True] 正しい(月の位相計算に使う大余小余)
|
56
|
+
# @return [True] 正しくない
|
57
|
+
#
|
58
|
+
def self.valid?(remainder:)
|
59
|
+
return if remainder.is_a?(Cycle::LunarRemainder)
|
60
|
+
|
61
|
+
raise ArgumentError, "unmatch parameter type: #{remainder.class}"
|
62
|
+
end
|
63
|
+
private_class_method :valid?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|