zakuro 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -12
- data/doc/operation/csv/month.csv +202 -202
- data/doc/operation/operation.xlsx +0 -0
- data/doc/operation/transfer.rb +6 -2
- 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 +471 -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/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/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/summary/single.rb +129 -0
- data/lib/zakuro/condition.rb +16 -13
- data/lib/zakuro/era/japan/gengou/parser.rb +1 -3
- data/lib/zakuro/era/japan/gengou/type.rb +3 -3
- data/lib/zakuro/era/japan/gengou/validator.rb +15 -13
- data/lib/zakuro/merchant.rb +2 -2
- data/lib/zakuro/operation/month/parser.rb +132 -36
- data/lib/zakuro/operation/month/type.rb +11 -10
- data/lib/zakuro/operation/month/validator.rb +332 -28
- data/lib/zakuro/operation/operation.rb +21 -0
- data/lib/zakuro/operation/yaml/month.yaml +1 -1
- 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/result/operation.rb +64 -36
- data/lib/zakuro/tools/stringifier.rb +2 -2
- 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/const/number.rb +51 -0
- data/lib/zakuro/version/senmyou/const/remainder.rb +43 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +61 -0
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +31 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +166 -181
- data/lib/zakuro/version/senmyou/range/annual_range.rb +86 -159
- 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 +45 -0
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +108 -0
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +89 -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 +175 -0
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
- data/lib/zakuro/version/senmyou/stella/solar/location.rb +164 -0
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +138 -0
- data/lib/zakuro/version/version_class_resolver.rb +62 -0
- data/lib/zakuro/version_factory.rb +2 -2
- metadata +38 -24
- 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 -76
- 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 -48
- 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 -167
- data/lib/zakuro/version/senmyou/range/full_range.rb +0 -324
- data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -105
- data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -163
- data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -99
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -214
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -394
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
- data/lib/zakuro/version/senmyou/summary/single.rb +0 -71
@@ -0,0 +1,45 @@
|
|
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 = \
|
38
|
+
total_year * YEAR - lunar_age.to_minute
|
39
|
+
|
40
|
+
Cycle::LunarRemainder.new(total: (total_day % ANOMALISTIC_MONTH))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../const/remainder'
|
4
|
+
|
5
|
+
require_relative './localization'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Senmyou
|
11
|
+
# :nodoc:
|
12
|
+
module Lunar
|
13
|
+
#
|
14
|
+
# Location 入暦
|
15
|
+
#
|
16
|
+
class Location
|
17
|
+
# @return [Cycle::LunarRemainder] 暦中日
|
18
|
+
HALF_ANOMALISTIC_MONTH = Const::Remainder::Lunar::HALF_ANOMALISTIC_MONTH
|
19
|
+
# @return [Cycle::LunarRemainder] 入暦上限
|
20
|
+
LIMIT = Const::Remainder::Lunar::LIMIT
|
21
|
+
# @return [Cycle::LunarRemainder] 弦
|
22
|
+
QUARTER = Const::Remainder::Lunar::QUARTER
|
23
|
+
|
24
|
+
# @return [True] 計算済み(前回計算あり)
|
25
|
+
# @return [False] 未計算(初回計算)
|
26
|
+
attr_reader :calculated
|
27
|
+
# @return [Integer] 西暦年
|
28
|
+
attr_reader :western_year
|
29
|
+
# @return [True] 進(遠地点より数える)
|
30
|
+
# @return [False] 退(近地点より数える)
|
31
|
+
attr_reader :forward
|
32
|
+
# @return [Cycle::LunarRemainder] 大余小余(初回:昨年天正閏余)
|
33
|
+
attr_reader :remainder
|
34
|
+
|
35
|
+
#
|
36
|
+
# 初期化
|
37
|
+
#
|
38
|
+
# @param [Cycle::LunarRemainder] lunar_age 天正閏余(大余小余)
|
39
|
+
# @param [Integer] western_year 西暦年
|
40
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
41
|
+
#
|
42
|
+
def initialize(lunar_age:, western_year:)
|
43
|
+
@calculated = false
|
44
|
+
@western_year = western_year
|
45
|
+
# 進
|
46
|
+
@forward = true
|
47
|
+
@remainder = lunar_age
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# 入暦を計算する
|
52
|
+
#
|
53
|
+
def run
|
54
|
+
if calculated
|
55
|
+
# 1始まりで計算しているので、入暦上限を用いる
|
56
|
+
decrease(limit: LIMIT)
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
60
|
+
first
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# 弦の分だけ月地点を進める
|
65
|
+
#
|
66
|
+
def add_quarter
|
67
|
+
@remainder.add!(QUARTER)
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
#
|
73
|
+
# 初回計算
|
74
|
+
#
|
75
|
+
def first
|
76
|
+
@remainder = Localization.first_remainder(
|
77
|
+
lunar_age: @remainder, western_year: @western_year
|
78
|
+
)
|
79
|
+
# 初回は0始まりで計算しているので、暦中日を用いる
|
80
|
+
decrease(limit: HALF_ANOMALISTIC_MONTH)
|
81
|
+
# 1始まりに改める
|
82
|
+
one_based
|
83
|
+
|
84
|
+
@calculated = true
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# 大余小余に合わせて減算する(折り返す)
|
89
|
+
#
|
90
|
+
# @param [Cycle::LunarRemainder] limit 上限
|
91
|
+
#
|
92
|
+
def decrease(limit:)
|
93
|
+
return if @remainder < limit
|
94
|
+
|
95
|
+
@remainder.sub!(HALF_ANOMALISTIC_MONTH)
|
96
|
+
@forward = !@forward
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# 1始まりにする
|
101
|
+
#
|
102
|
+
def one_based
|
103
|
+
@remainder.add!(Cycle::Remainder.new(day: 1, minute: 0, second: 0))
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../cycle/remainder'
|
4
|
+
|
5
|
+
require_relative './adjustment'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Senmyou
|
11
|
+
# :nodoc:
|
12
|
+
module Lunar
|
13
|
+
#
|
14
|
+
# Value 月補正値
|
15
|
+
#
|
16
|
+
module Value
|
17
|
+
# :reek:TooManyStatements { max_statements: 9 }
|
18
|
+
|
19
|
+
#
|
20
|
+
# 月の運行による補正値を算出する
|
21
|
+
#
|
22
|
+
# @param [Cycle::LunarRemainder] remainder 月の大余小余
|
23
|
+
# @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
|
24
|
+
#
|
25
|
+
# @return [Integer] 補正値
|
26
|
+
#
|
27
|
+
def self.get(remainder:, forward:)
|
28
|
+
valid?(remainder: remainder)
|
29
|
+
|
30
|
+
day = remainder.day
|
31
|
+
minute = remainder.floor_minute
|
32
|
+
|
33
|
+
# 引き当て
|
34
|
+
row = Adjustment.specify(forward: forward, day: day, minute: minute)
|
35
|
+
|
36
|
+
value = row.value
|
37
|
+
denominator = row.denominator
|
38
|
+
|
39
|
+
minus_minute = Adjustment.minus_minute(day: day, minute: minute)
|
40
|
+
|
41
|
+
day = calc_day(per: value.per, denominator: denominator,
|
42
|
+
minute: minus_minute)
|
43
|
+
|
44
|
+
value.stack + day
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# 大余小余を検証する
|
49
|
+
#
|
50
|
+
# @param [Cycle::LunarRemainder] remainder 大余小余
|
51
|
+
#
|
52
|
+
# @return [True] 正しい(月の位相計算に使う大余小余)
|
53
|
+
# @return [True] 正しくない
|
54
|
+
#
|
55
|
+
def self.valid?(remainder:)
|
56
|
+
return if remainder.is_a?(Cycle::LunarRemainder)
|
57
|
+
|
58
|
+
raise ArgumentError, "unmatch parameter type: #{remainder.class}"
|
59
|
+
end
|
60
|
+
private_class_method :valid?
|
61
|
+
|
62
|
+
# :reek:TooManyStatements { max_statements: 9 }
|
63
|
+
|
64
|
+
#
|
65
|
+
# 累計値(大余)を作成する
|
66
|
+
#
|
67
|
+
# @param [Integer] per 入暦(1-14)
|
68
|
+
# @param [Integer] denominator 小余の分母
|
69
|
+
# @param [Integer] minute 小余
|
70
|
+
#
|
71
|
+
# @return [Integer] 累計値(大余)
|
72
|
+
#
|
73
|
+
def self.calc_day(per:, denominator:, minute:)
|
74
|
+
remainder_minute = (per * minute).to_f
|
75
|
+
day = remainder_minute / denominator
|
76
|
+
# 切り捨て(プラスマイナスに関わらず小数点以下切り捨て)
|
77
|
+
day = day.negative? ? day.ceil : day.floor
|
78
|
+
sign = remainder_minute.negative? ? -1 : 1
|
79
|
+
remainder_day = (sign * remainder_minute) % denominator
|
80
|
+
# 四捨五入(8400ならその半分の4200以上を繰り上げる)
|
81
|
+
day += sign if remainder_day >= (denominator / 2)
|
82
|
+
|
83
|
+
day
|
84
|
+
end
|
85
|
+
private_class_method :calc_day
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './lunar_age'
|
4
|
+
require_relative './winter_solstice'
|
5
|
+
|
6
|
+
# :nodoc:
|
7
|
+
module Zakuro
|
8
|
+
# :nodoc:
|
9
|
+
module Senmyou
|
10
|
+
# :nodoc:
|
11
|
+
module Origin
|
12
|
+
#
|
13
|
+
# AverageNovember 11月経
|
14
|
+
#
|
15
|
+
module AverageNovember
|
16
|
+
#
|
17
|
+
# 11月経朔(冬至が含まれる月の1日)を求める
|
18
|
+
#
|
19
|
+
# @param [Integer] western_year 西暦年
|
20
|
+
#
|
21
|
+
# @return [Remainder] 11月経朔
|
22
|
+
#
|
23
|
+
def self.get(western_year:)
|
24
|
+
# 冬至
|
25
|
+
winter_solstice = WinterSolstice.get(western_year: western_year)
|
26
|
+
# 天正閏余
|
27
|
+
lunar_age = LunarAge.get(western_year: western_year)
|
28
|
+
|
29
|
+
winter_solstice.sub(lunar_age)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../output/logger'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Senmyou
|
11
|
+
# :nodoc:
|
12
|
+
module Origin
|
13
|
+
#
|
14
|
+
# LunarAge 天正閏余
|
15
|
+
#
|
16
|
+
module LunarAge
|
17
|
+
# @return [Integer] 朔望月
|
18
|
+
SYNODIC_MONTH = Const::Number::Cycle::SYNODIC_MONTH
|
19
|
+
# @return [Integer] 一年
|
20
|
+
YEAR = Const::Number::Cycle::YEAR
|
21
|
+
# @return [Integer] 積年
|
22
|
+
TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
|
23
|
+
# @return [Integer] 暦の開始年
|
24
|
+
BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
|
25
|
+
|
26
|
+
# @return [Output::Logger] ロガー
|
27
|
+
LOGGER = Output::Logger.new(location: 'lunar_age')
|
28
|
+
|
29
|
+
# :reek:TooManyStatements { max_statements: 7 }
|
30
|
+
|
31
|
+
#
|
32
|
+
# 対象年の天正閏余(冬至より前にある11月経朔との差 = 月齢)を算出する
|
33
|
+
# 太陽と月の運動による補正値を算出し、その補正結果を返す
|
34
|
+
#
|
35
|
+
# @param [Integer] western_year 西暦年
|
36
|
+
#
|
37
|
+
# @return [Remainder] 天正閏余
|
38
|
+
#
|
39
|
+
def self.get(western_year:)
|
40
|
+
# 積年の開始から対象年までの年数
|
41
|
+
total = TOTAL_YEAR + western_year - BEGIN_YEAR
|
42
|
+
|
43
|
+
# 12朔望月に対する1年の余り(単位:分)
|
44
|
+
remainder_minute = YEAR - (SYNODIC_MONTH * 12)
|
45
|
+
|
46
|
+
# 朔望月に含まれなかった余り(単位:年)
|
47
|
+
remainder_year = total % SYNODIC_MONTH
|
48
|
+
|
49
|
+
LOGGER.debug("[01]: #{remainder_year}")
|
50
|
+
|
51
|
+
# 天正閏余
|
52
|
+
lunar_age = remainder_minute * remainder_year % SYNODIC_MONTH
|
53
|
+
|
54
|
+
LOGGER.debug("[02]: #{lunar_age}")
|
55
|
+
|
56
|
+
# 大余・小余に変換する
|
57
|
+
Cycle::Remainder.new(total: lunar_age)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../../output/logger'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Senmyou
|
11
|
+
# :nodoc:
|
12
|
+
module Origin
|
13
|
+
#
|
14
|
+
# WinterSolstice 冬至
|
15
|
+
#
|
16
|
+
module WinterSolstice
|
17
|
+
# @return [Integer] 通余
|
18
|
+
REMAINDER_ALL_YEAR = Const::Number::Derivation::REMAINDER_ALL_YEAR
|
19
|
+
# @return [Integer] 60日
|
20
|
+
SIXTY_DAYS = Const::Number::Derivation::SIXTY_DAYS
|
21
|
+
# @return [Integer] 積年
|
22
|
+
TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
|
23
|
+
# @return [Integer] 暦の開始年
|
24
|
+
BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
|
25
|
+
|
26
|
+
# @return [Output::Logger] ロガー
|
27
|
+
LOGGER = Output::Logger.new(location: 'winter_solstice')
|
28
|
+
|
29
|
+
# :reek:TooManyStatements { max_statements: 6 }
|
30
|
+
|
31
|
+
#
|
32
|
+
# 対象年の前年の冬至を求める
|
33
|
+
#
|
34
|
+
# @param [Integer] western_year 西暦年
|
35
|
+
#
|
36
|
+
# @return [Remainder] 前年の冬至
|
37
|
+
#
|
38
|
+
def self.get(western_year:)
|
39
|
+
# 積年の開始から対象年までの年数
|
40
|
+
total = TOTAL_YEAR + western_year - BEGIN_YEAR
|
41
|
+
remainder_year = total % SIXTY_DAYS
|
42
|
+
|
43
|
+
LOGGER.debug("[01]:#{remainder_year}")
|
44
|
+
|
45
|
+
# 通余を使う
|
46
|
+
winter_solstice_minute = (remainder_year * REMAINDER_ALL_YEAR) % SIXTY_DAYS
|
47
|
+
|
48
|
+
LOGGER.debug("[02]:#{winter_solstice_minute}")
|
49
|
+
|
50
|
+
Cycle::Remainder.new(total: winter_solstice_minute)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../cycle/solar_term'
|
4
|
+
|
5
|
+
require_relative '../../const/number'
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Senmyou
|
11
|
+
# :nodoc:
|
12
|
+
module Solar
|
13
|
+
#
|
14
|
+
# Adjustment 24気損益眺朒(ちょうじく)数
|
15
|
+
#
|
16
|
+
module Adjustment
|
17
|
+
#
|
18
|
+
# Item 24気損益眺朒(ちょうじく)数
|
19
|
+
#
|
20
|
+
class Item
|
21
|
+
# @return [Integer] 眺朒(ちょうじく)積
|
22
|
+
attr_reader :stack
|
23
|
+
# @return [Integer] 眺朒(ちょうじく)数
|
24
|
+
attr_reader :per_term
|
25
|
+
# @return [Integer] 毎日差
|
26
|
+
attr_reader :per_day
|
27
|
+
|
28
|
+
#
|
29
|
+
# 初期化
|
30
|
+
#
|
31
|
+
# @param [Integer] stack 眺朒(ちょうじく)積
|
32
|
+
# @param [Integer] per_term 眺朒(ちょうじく)数
|
33
|
+
# @param [Integer] per_day 毎日差
|
34
|
+
#
|
35
|
+
def initialize(stack:, per_term:, per_day:)
|
36
|
+
@stack = stack
|
37
|
+
@per_term = per_term
|
38
|
+
@per_day = per_day
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# 文字化
|
43
|
+
#
|
44
|
+
# @return [String] 文字
|
45
|
+
#
|
46
|
+
def to_s
|
47
|
+
"stack:#{@stack}, per_term:#{@per_term}, per_day:#{@per_day}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [Array<Item>] 24気損益眺朒(ちょうじく)数
|
52
|
+
MAP = {
|
53
|
+
touji: Item.new(stack: 0.0, per_term: +33.4511, per_day: -0.3695), # 冬至(とうじ)
|
54
|
+
shoukan: Item.new(stack: +449.0, per_term: +28.0389, per_day: -0.3606), # 小寒(しょうかん)
|
55
|
+
daikan: Item.new(stack: +823.0, per_term: +22.6998, per_day: -0.3519), # 大寒(だいかん)
|
56
|
+
risshun: Item.new(stack: +1122.0, per_term: +17.8923, per_day: -0.4068), # 立春(りっしゅん)
|
57
|
+
usui: Item.new(stack: +1346.0, per_term: +11.7966, per_day: -0.3998), # 雨水(うすい)
|
58
|
+
keichitsu: Item.new(stack: +1481.0, per_term: +5.7986, per_day: -0.3998), # 啓蟄(けいちつ)
|
59
|
+
shunbun: Item.new(stack: +1526.0, per_term: -0.2433, per_day: -0.3779), # 春分(しゅんぶん)
|
60
|
+
seimei: Item.new(stack: +1481.0, per_term: -6.1254, per_day: -0.3634), # 清明(せいめい)
|
61
|
+
kokuu: Item.new(stack: +1346.0, per_term: -12.2048, per_day: -0.2987), # 穀雨(こくう)
|
62
|
+
rikka: Item.new(stack: +1122.0, per_term: -16.9060, per_day: -0.2919), # 立夏(りっか)
|
63
|
+
shouman: Item.new(stack: +823.0, per_term: -21.5362, per_day: -0.2854), # 小満(しょうまん)
|
64
|
+
boushu: Item.new(stack: +449.0, per_term: -26.0498, per_day: -0.2854), # 芒種(ぼうしゅ)
|
65
|
+
geshi: Item.new(stack: 0.0, per_term: -30.3119, per_day: +0.2854), # 夏至(げし)
|
66
|
+
shousho: Item.new(stack: -449.0, per_term: -25.8126, per_day: +0.2919), # 小暑(しょうしょ)
|
67
|
+
taisho: Item.new(stack: -823.0, per_term: -21.2454, per_day: +0.2987), # 大暑(たいしょ)
|
68
|
+
risshuu: Item.new(stack: -1122.0, per_term: -17.0296, per_day: +0.3634), # 立秋(りっしゅう)
|
69
|
+
shosho: Item.new(stack: -1346.0, per_term: -11.4744, per_day: +0.3779), # 処暑(しょしょ)
|
70
|
+
hakuro: Item.new(stack: -1481.0, per_term: -5.6429, per_day: +0.3779), # 白露(はくろ)
|
71
|
+
shuubun: Item.new(stack: -1526.0, per_term: +0.1432, per_day: +0.3998), # 秋分(しゅうぶん)
|
72
|
+
kanro: Item.new(stack: -1481.0, per_term: +6.1488, per_day: +0.4068), # 寒露(かんろ)
|
73
|
+
soukou: Item.new(stack: -1346.0, per_term: +12.6336, per_day: +0.3519), # 霜降(そうこう)
|
74
|
+
rittou: Item.new(stack: -1122.0, per_term: +17.8043, per_day: +0.3606), # 立冬(りっとう)
|
75
|
+
shousetsu: Item.new(stack: -823.0, per_term: +23.0590, per_day: +0.3695), # 小雪(しょうせつ)
|
76
|
+
taisetsu: Item.new(stack: -449.0, per_term: +28.4618, per_day: +0.3695) # 大雪(たいせつ)
|
77
|
+
}.freeze
|
78
|
+
|
79
|
+
#
|
80
|
+
# 24気損益眺朒(ちょうじく)数を特定する
|
81
|
+
#
|
82
|
+
# @param [Integer] index 連番(二十四節気)
|
83
|
+
#
|
84
|
+
# @return [Adjustment::Item] 24気損益眺朒(ちょうじく)数
|
85
|
+
#
|
86
|
+
def self.specify(index:)
|
87
|
+
key = Cycle::SolarTerm::ORDER[index]
|
88
|
+
Adjustment::MAP[key].clone
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|