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
@@ -0,0 +1,151 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './abstract_remainder'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Calculation
|
9
|
+
# :nodoc:
|
10
|
+
module Cycle
|
11
|
+
#
|
12
|
+
# AbstractSolarTerm 二十四節気
|
13
|
+
#
|
14
|
+
class AbstractSolarTerm
|
15
|
+
# @return [Integer] 連番
|
16
|
+
attr_reader :index
|
17
|
+
# @return [AbstractRemainder] 時刻情報(大余小余)
|
18
|
+
attr_reader :remainder
|
19
|
+
# @return [AbstractRemainder] 気策(24分の1年)
|
20
|
+
attr_reader :average
|
21
|
+
|
22
|
+
# @return [Hash<Integer, Symbol>] 順序
|
23
|
+
ORDER = {
|
24
|
+
0 => :touji,
|
25
|
+
1 => :shoukan,
|
26
|
+
2 => :daikan,
|
27
|
+
3 => :risshun,
|
28
|
+
4 => :usui,
|
29
|
+
5 => :keichitsu,
|
30
|
+
6 => :shunbun,
|
31
|
+
7 => :seimei,
|
32
|
+
8 => :kokuu,
|
33
|
+
9 => :rikka,
|
34
|
+
10 => :shouman,
|
35
|
+
11 => :boushu,
|
36
|
+
12 => :geshi,
|
37
|
+
13 => :shousho,
|
38
|
+
14 => :taisho,
|
39
|
+
15 => :risshuu,
|
40
|
+
16 => :shosho,
|
41
|
+
17 => :hakuro,
|
42
|
+
18 => :shuubun,
|
43
|
+
19 => :kanro,
|
44
|
+
20 => :soukou,
|
45
|
+
21 => :rittou,
|
46
|
+
22 => :shousetsu,
|
47
|
+
23 => :taisetsu
|
48
|
+
}.freeze
|
49
|
+
|
50
|
+
#
|
51
|
+
# 初期化
|
52
|
+
#
|
53
|
+
# @param [Integer] index 連番
|
54
|
+
# @param [AbstractRemainder] remainder 時刻情報(大余小余)
|
55
|
+
#
|
56
|
+
def initialize(index: -1, remainder: AbstractRemainder.new,
|
57
|
+
average: AbstractRemainder.new)
|
58
|
+
@index = index
|
59
|
+
@remainder = remainder
|
60
|
+
@average = average
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# 不正かどうか検証する
|
65
|
+
#
|
66
|
+
# @return [True] 正しくない
|
67
|
+
# @return [False] 正しい
|
68
|
+
#
|
69
|
+
def invalid?
|
70
|
+
(@index == -1 || @remainder.invalid?)
|
71
|
+
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# データなしかを検証する
|
75
|
+
#
|
76
|
+
# @return [True] データなし
|
77
|
+
# @return [False] データあり
|
78
|
+
#
|
79
|
+
def empty?
|
80
|
+
(@index == -1 && @remainder.invalid?)
|
81
|
+
end
|
82
|
+
|
83
|
+
def index?(index)
|
84
|
+
result = ORDER.fetch(index, -1)
|
85
|
+
|
86
|
+
result != -1
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# 次の二十四節気に進める
|
91
|
+
#
|
92
|
+
def next!
|
93
|
+
@index += 1
|
94
|
+
@index = 0 if @index >= ORDER.size
|
95
|
+
|
96
|
+
@remainder.add!(@average)
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# 指定した連番の二十四節気まで進める
|
101
|
+
#
|
102
|
+
# @param [Integer] index 連番
|
103
|
+
#
|
104
|
+
def next_by_index(index)
|
105
|
+
return ArgumentError.new, 'invalid index' unless index?(index)
|
106
|
+
|
107
|
+
loop do
|
108
|
+
return if @index == index
|
109
|
+
|
110
|
+
next!
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
#
|
115
|
+
# 指定した連番の二十四節気まで戻す
|
116
|
+
#
|
117
|
+
# @param [Integer] index 連番
|
118
|
+
#
|
119
|
+
def prev_by_index(index)
|
120
|
+
return ArgumentError.new, 'invalid index' unless index?(index)
|
121
|
+
|
122
|
+
loop do
|
123
|
+
return if @index == index
|
124
|
+
|
125
|
+
prev!
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
#
|
130
|
+
# 前の二十四節気に戻る
|
131
|
+
#
|
132
|
+
def prev!
|
133
|
+
@index -= 1
|
134
|
+
@index = 23 if @index.negative?
|
135
|
+
|
136
|
+
@remainder.sub!(@average)
|
137
|
+
end
|
138
|
+
|
139
|
+
#
|
140
|
+
# ディープコピー
|
141
|
+
#
|
142
|
+
# @param [SolarTerm] obj 自身
|
143
|
+
#
|
144
|
+
def initialize_copy(obj)
|
145
|
+
@index = obj.index.clone
|
146
|
+
@remainder = obj.remainder.clone
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
# :nodoc:
|
6
|
+
module Calculation
|
7
|
+
# :nodoc:
|
8
|
+
module Cycle
|
9
|
+
#
|
10
|
+
# Zodiac 十干十二支
|
11
|
+
#
|
12
|
+
module Zodiac
|
13
|
+
# @return [Hash<Integer, String>] 十干十二支
|
14
|
+
ZODIAC_NAME_PATTERNS = {
|
15
|
+
0 => '甲子', # きのえね
|
16
|
+
1 => '乙丑', # きのとうし
|
17
|
+
2 => '丙寅', # ひのえとら
|
18
|
+
3 => '丁卯', # ひのとう
|
19
|
+
4 => '戊辰', # つちのえたつ
|
20
|
+
5 => '己巳', # つちのとみ
|
21
|
+
6 => '庚午', # かのえうま
|
22
|
+
7 => '辛未', # かのとひつじ
|
23
|
+
8 => '壬申', # みずのえさる
|
24
|
+
9 => '癸酉', # みずのととり
|
25
|
+
10 => '甲戌', # きのえいぬ
|
26
|
+
11 => '乙亥', # きのとい
|
27
|
+
12 => '丙子', # ひのえね
|
28
|
+
13 => '丁丑', # ひのとうし
|
29
|
+
14 => '戊寅', # つちのえとら
|
30
|
+
15 => '己卯', # つちのとう
|
31
|
+
16 => '庚辰', # かのえたつ
|
32
|
+
17 => '辛巳', # かのとみ
|
33
|
+
18 => '壬午', # みずのえうま
|
34
|
+
19 => '癸未', # みずのとひつじ
|
35
|
+
20 => '甲申', # きのえさる
|
36
|
+
21 => '乙酉', # きのととり
|
37
|
+
22 => '丙戌', # ひのえいぬ
|
38
|
+
23 => '丁亥', # ひのとい
|
39
|
+
24 => '戊子', # つちのえね
|
40
|
+
25 => '己丑', # つちのとうし
|
41
|
+
26 => '庚寅', # かのえとら
|
42
|
+
27 => '辛卯', # かのとう
|
43
|
+
28 => '壬辰', # みずのえたつ
|
44
|
+
29 => '癸巳', # みずのとみ
|
45
|
+
30 => '甲午', # きのえうま
|
46
|
+
31 => '乙未', # きのとひつじ
|
47
|
+
32 => '丙申', # ひのえさる
|
48
|
+
33 => '丁酉', # ひのととり
|
49
|
+
34 => '戊戌', # つちのえいぬ
|
50
|
+
35 => '己亥', # つちのとい
|
51
|
+
36 => '庚子', # かのえね
|
52
|
+
37 => '辛丑', # かのとうし
|
53
|
+
38 => '壬寅', # みずのえとら
|
54
|
+
39 => '癸卯', # みずのとう
|
55
|
+
40 => '甲辰', # きのえたつ
|
56
|
+
41 => '乙巳', # きのとみ
|
57
|
+
42 => '丙午', # ひのえうま
|
58
|
+
43 => '丁未', # ひのとひつじ
|
59
|
+
44 => '戊申', # つちのえさる
|
60
|
+
45 => '己酉', # つちのととり
|
61
|
+
46 => '庚戌', # かのえいぬ
|
62
|
+
47 => '辛亥', # かのとい
|
63
|
+
48 => '壬子', # みずのえね
|
64
|
+
49 => '癸丑', # みずのとうし
|
65
|
+
50 => '甲寅', # きのえとら
|
66
|
+
51 => '乙卯', # きのとう
|
67
|
+
52 => '丙辰', # ひのえたつ
|
68
|
+
53 => '丁巳', # ひのとみ
|
69
|
+
54 => '戊午', # つちのえうま
|
70
|
+
55 => '己未', # つちのとひつじ
|
71
|
+
56 => '庚申', # かのえさる
|
72
|
+
57 => '辛酉', # かのととり
|
73
|
+
58 => '壬戌', # みずのえいぬ
|
74
|
+
59 => '癸亥' # みずのとい
|
75
|
+
}.freeze
|
76
|
+
|
77
|
+
# @return [Integer] 組み合わせ数
|
78
|
+
LENGTH = ZODIAC_NAME_PATTERNS.length
|
79
|
+
|
80
|
+
#
|
81
|
+
# 大余を十干十二支に変換する
|
82
|
+
#
|
83
|
+
# @param [Integer] day 大余
|
84
|
+
#
|
85
|
+
# @return [String] 十干十二支
|
86
|
+
#
|
87
|
+
def self.day_name(day:)
|
88
|
+
index = day % LENGTH
|
89
|
+
|
90
|
+
ZODIAC_NAME_PATTERNS[index]
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# 西暦年を十干十二支に変換する
|
95
|
+
#
|
96
|
+
# @param [Integer] western_year 西暦年
|
97
|
+
#
|
98
|
+
# @return [String] 十干十二支
|
99
|
+
#
|
100
|
+
def self.year_name(western_year: 0)
|
101
|
+
ZODIAC_NAME_PATTERNS[(western_year - 4) % LENGTH]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../era/western'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Calculation
|
9
|
+
# :nodoc:
|
10
|
+
module Monthly
|
11
|
+
#
|
12
|
+
# FirstDay 月初日(朔日)
|
13
|
+
#
|
14
|
+
class FirstDay
|
15
|
+
# @return [Western::Calendar] 西暦日
|
16
|
+
attr_reader :western_date
|
17
|
+
# @return [Remainder] 大余小余
|
18
|
+
attr_reader :remainder
|
19
|
+
|
20
|
+
#
|
21
|
+
# 初期化
|
22
|
+
#
|
23
|
+
# @param [Remainder] remainder 西暦日
|
24
|
+
# @param [Western::Calendar] western_date 大余小余
|
25
|
+
#
|
26
|
+
def initialize(western_date: Western::Calendar.new, remainder: Remainder.new)
|
27
|
+
# 西暦日
|
28
|
+
@western_date = western_date
|
29
|
+
# 大余小余
|
30
|
+
@remainder = remainder
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# ディープコピー
|
35
|
+
#
|
36
|
+
# @param [FirstDay] obj 自身
|
37
|
+
#
|
38
|
+
def initialize_copy(obj)
|
39
|
+
@western_date = obj.western_date.clone
|
40
|
+
@remainder = obj.remainder.clone
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './month'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Calculation
|
9
|
+
# :nodoc:
|
10
|
+
module Monthly
|
11
|
+
#
|
12
|
+
# InitializedMonth 初期月情報
|
13
|
+
#
|
14
|
+
class InitializedMonth < Month
|
15
|
+
# @return [True] 昨年の月
|
16
|
+
# @return [False] 今年の月
|
17
|
+
# @note 冬至基準で1年データを作成するため昨年の11月-12月である可能性がある
|
18
|
+
attr_reader :is_last_year
|
19
|
+
# @return [Integer] 月齢(朔月、上弦、望月、下弦)
|
20
|
+
attr_reader :phase_index
|
21
|
+
|
22
|
+
# :reek:ControlParameter and :reek:BooleanParameter
|
23
|
+
|
24
|
+
#
|
25
|
+
# 初期化
|
26
|
+
#
|
27
|
+
# @param [MonthLabel] month_label 月表示名
|
28
|
+
# @param [Array<SolarTerm>] solar_terms 二十四節気
|
29
|
+
# @param [FirstDay] first_day 月初日(朔日)
|
30
|
+
# @param [True, False] is_last_year 昨年の月/今年の月
|
31
|
+
# @param [Integer] phase_index 月齢(朔月、上弦、望月、下弦)
|
32
|
+
#
|
33
|
+
def initialize(month_label: MonthLabel.new, solar_terms: [], first_day: FirstDay.new,
|
34
|
+
is_last_year: false, phase_index: -1)
|
35
|
+
super(month_label: month_label, solar_terms: solar_terms, first_day: first_day)
|
36
|
+
@is_last_year = is_last_year
|
37
|
+
@phase_index = phase_index
|
38
|
+
end
|
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
|
+
|
102
|
+
#
|
103
|
+
# 一ヶ月戻す
|
104
|
+
#
|
105
|
+
def back_to_last_month
|
106
|
+
@is_last_year = true if month_label.back_to_last_month
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# 二十四節気の数を返す
|
111
|
+
#
|
112
|
+
# @return [Integer] 二十四節気の数
|
113
|
+
#
|
114
|
+
def solar_term_size
|
115
|
+
solar_terms.size
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../cycle/abstract_solar_term'
|
4
|
+
|
5
|
+
require_relative './first_day'
|
6
|
+
require_relative './month_label'
|
7
|
+
|
8
|
+
# :nodoc:
|
9
|
+
module Zakuro
|
10
|
+
# :nodoc:
|
11
|
+
module Calculation
|
12
|
+
# :nodoc:
|
13
|
+
module Monthly
|
14
|
+
#
|
15
|
+
# Month 月情報
|
16
|
+
#
|
17
|
+
class Month
|
18
|
+
# @return [MonthLabel] 月表示名
|
19
|
+
attr_reader :month_label
|
20
|
+
# @return [FirstDay] 月初日(朔日)
|
21
|
+
attr_reader :first_day
|
22
|
+
# @return [Array<SolarTerm>] 二十四節気
|
23
|
+
attr_reader :solar_terms
|
24
|
+
|
25
|
+
#
|
26
|
+
# 初期化
|
27
|
+
#
|
28
|
+
# @param [MonthLabel] month_label 月表示名
|
29
|
+
# @param [FirstDay] first_day 月初日(朔日)
|
30
|
+
# @param [Array<SolarTerm>] solar_terms 二十四節気
|
31
|
+
#
|
32
|
+
def initialize(month_label: MonthLabel.new, first_day: FirstDay.new, solar_terms: [])
|
33
|
+
@month_label = month_label
|
34
|
+
@first_day = first_day
|
35
|
+
@solar_terms = solar_terms
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# 中気なしは閏月とする
|
40
|
+
#
|
41
|
+
def eval_leaped
|
42
|
+
leaped = even_term.invalid?
|
43
|
+
|
44
|
+
@month_label = MonthLabel.new(number: number, is_many_days: many_days?, leaped: leaped)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# 月初日の西暦日を返す
|
49
|
+
#
|
50
|
+
# @return [Western::Calendar] 西暦日
|
51
|
+
#
|
52
|
+
def western_date
|
53
|
+
@first_day.western_date
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# 月初日の大余小余を返す
|
58
|
+
#
|
59
|
+
# @return [Remainder] 大余小余
|
60
|
+
#
|
61
|
+
def remainder
|
62
|
+
@first_day.remainder
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# 月の大小を返す
|
67
|
+
#
|
68
|
+
# @return [True] 大の月(30日)
|
69
|
+
# @return [False] 小の月(29日)
|
70
|
+
#
|
71
|
+
def many_days?
|
72
|
+
@month_label.is_many_days
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
# 月の日数を返す
|
77
|
+
#
|
78
|
+
# @return [Integer] 日数
|
79
|
+
#
|
80
|
+
def days
|
81
|
+
@month_label.days
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# 月の名前(大小)を返す
|
86
|
+
#
|
87
|
+
# @return [String] 月の名前(大小)
|
88
|
+
#
|
89
|
+
def days_name
|
90
|
+
@month_label.days_name
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# 月を返す
|
95
|
+
#
|
96
|
+
# @return [Integer] 月(xx月のxx)
|
97
|
+
#
|
98
|
+
def number
|
99
|
+
@month_label.number
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# 閏を返す
|
104
|
+
#
|
105
|
+
# @return [True] 閏月
|
106
|
+
# @return [False] 平月
|
107
|
+
#
|
108
|
+
def leaped?
|
109
|
+
@month_label.leaped
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# 次月の大余から月の日数を定める
|
114
|
+
#
|
115
|
+
# @param [Integer] next_month_day 次月の大余
|
116
|
+
#
|
117
|
+
def eval_many_days(next_month_day:)
|
118
|
+
is_many_days = remainder.same_remainder_divided_by_ten?(other: next_month_day)
|
119
|
+
|
120
|
+
@month_label = MonthLabel.new(
|
121
|
+
number: number, is_many_days: is_many_days, leaped: leaped?
|
122
|
+
)
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# 二十四節気が未設定かどうかを検証する
|
127
|
+
#
|
128
|
+
# @return [True] 設定なし
|
129
|
+
# @return [False] 設定あり
|
130
|
+
#
|
131
|
+
def empty_solar_term?
|
132
|
+
@solar_terms.empty?
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# 中気を返す
|
137
|
+
#
|
138
|
+
# @return [SolarTerm] 中気
|
139
|
+
#
|
140
|
+
def even_term
|
141
|
+
@solar_terms.each do |term|
|
142
|
+
return term if term.index.even?
|
143
|
+
end
|
144
|
+
|
145
|
+
Cycle::AbstractSolarTerm.new
|
146
|
+
end
|
147
|
+
|
148
|
+
#
|
149
|
+
# 節気を返す
|
150
|
+
#
|
151
|
+
# @return [SolarTerm] 節気
|
152
|
+
#
|
153
|
+
def odd_term
|
154
|
+
@solar_terms.each do |term|
|
155
|
+
return term if term.index.odd?
|
156
|
+
end
|
157
|
+
|
158
|
+
Cycle::AbstractSolarTerm.new
|
159
|
+
end
|
160
|
+
|
161
|
+
#
|
162
|
+
# 二十四節気を追加する
|
163
|
+
#
|
164
|
+
# @param [SolarTerm] term 二十四節気
|
165
|
+
#
|
166
|
+
def add_term(term:)
|
167
|
+
@solar_terms.push(term)
|
168
|
+
end
|
169
|
+
|
170
|
+
#
|
171
|
+
# 同一の月情報かを検証する
|
172
|
+
#
|
173
|
+
# @param [Month] other 他の月情報
|
174
|
+
#
|
175
|
+
# @return [True] 同一の月
|
176
|
+
# @return [False] 異なる月
|
177
|
+
#
|
178
|
+
def same?(other:)
|
179
|
+
number == other.number && leaped? == other.leaped?
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|