zakuro 0.0.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/.editorconfig +4 -0
- data/.gitignore +7 -1
- data/.rubocop.yml +3 -0
- data/Gemfile +2 -0
- data/Makefile +2 -0
- data/README.md +126 -33
- data/Rakefile +1 -1
- data/doc/gengou.md +315 -0
- data/doc/operation.md +25 -0
- data/doc/operation/csv/month.csv +202 -0
- data/doc/operation/operation.xlsx +0 -0
- data/doc/operation/transfer.rb +77 -0
- data/lib/zakuro/condition.rb +19 -15
- data/lib/zakuro/cycle/abstract_remainder.rb +3 -4
- data/lib/zakuro/era/japan/gengou.rb +106 -0
- data/lib/zakuro/era/japan/gengou/parser.rb +167 -0
- data/lib/zakuro/era/japan/gengou/type.rb +178 -0
- data/lib/zakuro/era/japan/gengou/validator.rb +236 -0
- data/lib/zakuro/era/japan/reki.rb +91 -0
- data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +1121 -0
- data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +485 -0
- data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +28 -0
- data/lib/zakuro/era/western.rb +11 -1
- data/lib/zakuro/operation/month/parser.rb +373 -0
- data/lib/zakuro/operation/month/type.rb +453 -0
- data/lib/zakuro/operation/month/validator.rb +802 -0
- data/lib/zakuro/operation/operation.rb +66 -0
- data/lib/zakuro/operation/yaml/month.yaml +6452 -0
- data/lib/zakuro/output/error.rb +2 -0
- data/lib/zakuro/output/logger.rb +2 -0
- data/lib/zakuro/output/response.rb +21 -19
- data/lib/zakuro/result/core.rb +52 -0
- data/lib/zakuro/result/data.rb +187 -0
- data/lib/zakuro/result/operation.rb +114 -0
- data/lib/zakuro/result/result.rb +37 -0
- data/lib/zakuro/{output → tools}/stringifier.rb +16 -9
- data/lib/zakuro/tools/typeof.rb +33 -0
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/senmyou/README.md +3 -1
- data/lib/zakuro/version/senmyou/base/era.rb +3 -1
- data/lib/zakuro/version/senmyou/base/multi_gengou.rb +98 -0
- data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +217 -0
- data/lib/zakuro/version/senmyou/base/remainder.rb +4 -4
- data/lib/zakuro/version/senmyou/base/solar_term.rb +82 -0
- data/lib/zakuro/version/senmyou/base/year.rb +52 -6
- data/lib/zakuro/version/senmyou/monthly/first_day.rb +44 -0
- data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +119 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +3 -3
- data/lib/zakuro/version/senmyou/monthly/month.rb +136 -67
- data/lib/zakuro/version/senmyou/monthly/month_label.rb +87 -0
- data/lib/zakuro/version/senmyou/monthly/operated_month.rb +196 -0
- data/lib/zakuro/version/senmyou/{summary/annual_data.rb → range/annual_range.rb} +34 -61
- data/lib/zakuro/version/senmyou/range/full_range.rb +194 -0
- data/lib/zakuro/version/senmyou/range/operated_range.rb +126 -0
- data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +181 -0
- 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/senmyou.rb +2 -2
- data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +102 -0
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +2 -2
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +105 -128
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +213 -0
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +4 -189
- data/lib/zakuro/version/senmyou/summary/single.rb +125 -0
- data/lib/zakuro/version_factory.rb +1 -1
- metadata +46 -15
- data/lib/zakuro/era/gengou/set-001-until-south.yaml +0 -375
- data/lib/zakuro/era/gengou/set-002-from-north.yaml +0 -166
- data/lib/zakuro/era/gengou/set-003-modern.yaml +0 -12
- data/lib/zakuro/era/japan.rb +0 -630
- data/lib/zakuro/output/result.rb +0 -219
- data/lib/zakuro/version/senmyou/base/gengou.rb +0 -210
- data/lib/zakuro/version/senmyou/summary/gengou_data.rb +0 -294
@@ -29,8 +29,8 @@ module Zakuro
|
|
29
29
|
# @param [Integer] total 繰り上げなしの小余
|
30
30
|
#
|
31
31
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
32
|
-
super(
|
33
|
-
|
32
|
+
super(base_day: DAY, base_mitune: MINUTE,
|
33
|
+
day: day, minute: minute, second: second, total: total)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -52,8 +52,8 @@ module Zakuro
|
|
52
52
|
# @param [Integer] total 繰り上げなしの小余
|
53
53
|
#
|
54
54
|
def initialize(day: -1, minute: -1, second: -1, total: -1)
|
55
|
-
super(
|
56
|
-
|
55
|
+
super(base_day: DAY, base_mitune: MINUTE,
|
56
|
+
day: day, minute: minute, second: second, total: total)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -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,
|
@@ -61,6 +67,82 @@ module Zakuro
|
|
61
67
|
def invalid?
|
62
68
|
(@index == -1 || @remainder.invalid?)
|
63
69
|
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# データなしかを検証する
|
73
|
+
#
|
74
|
+
# @return [True] データなし
|
75
|
+
# @return [False] データあり
|
76
|
+
#
|
77
|
+
def empty?
|
78
|
+
(@index == -1 && @remainder.invalid?)
|
79
|
+
end
|
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
|
+
|
137
|
+
#
|
138
|
+
# ディープコピー
|
139
|
+
#
|
140
|
+
# @param [SolarTerm] obj 自身
|
141
|
+
#
|
142
|
+
def initialize_copy(obj)
|
143
|
+
@index = obj.index.clone
|
144
|
+
@remainder = obj.remainder.clone
|
145
|
+
end
|
64
146
|
end
|
65
147
|
end
|
66
148
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './era'
|
4
|
+
|
3
5
|
# :nodoc:
|
4
6
|
module Zakuro
|
5
7
|
# :nodoc:
|
@@ -9,18 +11,63 @@ module Zakuro
|
|
9
11
|
#
|
10
12
|
class Year
|
11
13
|
# @return [Gengou] 元号
|
12
|
-
attr_reader :
|
14
|
+
attr_reader :multi_gengou
|
13
15
|
# @return [Array<Month>] 年内の全ての月
|
14
16
|
attr_reader :months
|
17
|
+
# @return [Integer] 年の日数
|
18
|
+
attr_reader :total_days
|
19
|
+
# @return [Western::Calendar] 元旦
|
20
|
+
attr_reader :new_year_date
|
15
21
|
|
16
22
|
#
|
17
23
|
# 初期化
|
18
24
|
#
|
19
|
-
# @param [Gengou]
|
25
|
+
# @param [Gengou] multi_gengou 元号
|
26
|
+
#
|
27
|
+
def initialize(multi_gengou: MultiGengou.new, new_year_date: Western::Calendar.new,
|
28
|
+
months: [], total_days: 0)
|
29
|
+
@multi_gengou = multi_gengou
|
30
|
+
@months = months
|
31
|
+
@new_year_date = new_year_date
|
32
|
+
@total_days = total_days
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# 年の日数を確定する
|
37
|
+
#
|
38
|
+
def commit
|
39
|
+
@total_days = 0
|
40
|
+
months.each do |month|
|
41
|
+
@total_days += month.days
|
42
|
+
end
|
43
|
+
|
44
|
+
self
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# 次年にする
|
49
|
+
#
|
50
|
+
# @param [Japan::Gengou] first_line 元号(1行目)
|
51
|
+
# @param [Japan::Gengou] second_line 元号(2行目)
|
52
|
+
#
|
53
|
+
# @return [MultiGengou] 自身
|
54
|
+
#
|
55
|
+
def next_year
|
56
|
+
@multi_gengou.next_year
|
57
|
+
|
58
|
+
@new_year_date += @total_days
|
59
|
+
@total_days = 0
|
60
|
+
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# 十干十二支を取得する
|
66
|
+
#
|
67
|
+
# @return [String] 十干十二支
|
20
68
|
#
|
21
|
-
def
|
22
|
-
@
|
23
|
-
@months = []
|
69
|
+
def zodiac_name
|
70
|
+
Era.zodiac_name(western_year: @new_year_date.year)
|
24
71
|
end
|
25
72
|
|
26
73
|
#
|
@@ -32,7 +79,6 @@ module Zakuro
|
|
32
79
|
return if duplicated?(month: month)
|
33
80
|
|
34
81
|
@months.push(month)
|
35
|
-
@gengou.add_days(days: month.days)
|
36
82
|
|
37
83
|
nil
|
38
84
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../era/western'
|
4
|
+
|
5
|
+
# TODO: moduleでMonthly とする(全暦むけに共通化したあと)
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Senmyou
|
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
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './month'
|
4
|
+
|
5
|
+
# TODO: moduleでMonthly とする(全暦むけに共通化したあと)
|
6
|
+
|
7
|
+
# :nodoc:
|
8
|
+
module Zakuro
|
9
|
+
# :nodoc:
|
10
|
+
module Senmyou
|
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
|
@@ -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
|
# 入定気
|
@@ -145,7 +145,7 @@ module Zakuro
|
|
145
145
|
# @return [Remainder] 定朔
|
146
146
|
#
|
147
147
|
def current_remainder
|
148
|
-
debug(
|
148
|
+
debug("@average_remainder.format: #{@average_remainder.format}")
|
149
149
|
|
150
150
|
sum = correction_value
|
151
151
|
adjusted = @average_remainder.add(
|
@@ -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')}")
|
@@ -1,5 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './first_day'
|
4
|
+
require_relative './month_label'
|
5
|
+
|
6
|
+
# TODO: moduleでMonthly とする(全暦むけに共通化したあと)
|
7
|
+
|
3
8
|
# :nodoc:
|
4
9
|
module Zakuro
|
5
10
|
# :nodoc:
|
@@ -8,63 +13,62 @@ module Zakuro
|
|
8
13
|
# Month 月情報
|
9
14
|
#
|
10
15
|
class Month
|
11
|
-
# @return [
|
12
|
-
|
13
|
-
# @
|
14
|
-
|
15
|
-
# @return [
|
16
|
-
|
17
|
-
attr_accessor :is_many_days
|
18
|
-
# @return [Integer] 月(xx月のxx)
|
19
|
-
attr_accessor :number
|
20
|
-
# @return [True] 閏月
|
21
|
-
# @return [False] 平月
|
22
|
-
attr_accessor :leaped
|
23
|
-
# @return [SolarTerm] 二十四節気(中気)
|
24
|
-
attr_accessor :even_term
|
25
|
-
# @return [SolarTerm] 二十四節気(節気)
|
26
|
-
attr_accessor :odd_term
|
27
|
-
# @return [Remainder] 月初日の大余小余
|
28
|
-
attr_reader :remainder
|
29
|
-
# @return [String] 月齢(朔月、上弦、望月、下弦)
|
30
|
-
attr_reader :phase_index
|
31
|
-
|
32
|
-
# rubocop:disable Metrics/ParameterLists
|
33
|
-
# :reek:BooleanParametere
|
16
|
+
# @return [MonthLabel] 月表示名
|
17
|
+
attr_reader :month_label
|
18
|
+
# @return [FirstDay] 月初日(朔日)
|
19
|
+
attr_reader :first_day
|
20
|
+
# @return [Array<SolarTerm>] 二十四節気
|
21
|
+
attr_reader :solar_terms
|
34
22
|
|
35
23
|
#
|
36
24
|
# 初期化
|
37
25
|
#
|
38
|
-
# @param [
|
39
|
-
# @param [
|
40
|
-
# @param [
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
@
|
64
|
-
|
65
|
-
|
26
|
+
# @param [MonthLabel] month_label 月表示名
|
27
|
+
# @param [FirstDay] first_day 月初日(朔日)
|
28
|
+
# @param [Array<SolarTerm>] solar_terms 二十四節気
|
29
|
+
#
|
30
|
+
def initialize(month_label: MonthLabel.new, first_day: FirstDay.new, solar_terms: [])
|
31
|
+
@month_label = month_label
|
32
|
+
@first_day = first_day
|
33
|
+
@solar_terms = solar_terms
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# 中気なしは閏月とする
|
38
|
+
#
|
39
|
+
def eval_leaped
|
40
|
+
leaped = even_term.invalid?
|
41
|
+
|
42
|
+
@month_label = MonthLabel.new(number: number, is_many_days: many_days?, leaped: leaped)
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# 月初日の西暦日を返す
|
47
|
+
#
|
48
|
+
# @return [Western::Calendar] 西暦日
|
49
|
+
#
|
50
|
+
def western_date
|
51
|
+
@first_day.western_date
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# 月初日の大余小余を返す
|
56
|
+
#
|
57
|
+
# @return [Remainder] 大余小余
|
58
|
+
#
|
59
|
+
def remainder
|
60
|
+
@first_day.remainder
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# 月の大小を返す
|
65
|
+
#
|
66
|
+
# @return [True] 大の月(30日)
|
67
|
+
# @return [False] 小の月(29日)
|
68
|
+
#
|
69
|
+
def many_days?
|
70
|
+
@month_label.is_many_days
|
66
71
|
end
|
67
|
-
# rubocop:enable Metrics/ParameterLists
|
68
72
|
|
69
73
|
#
|
70
74
|
# 月の日数を返す
|
@@ -72,7 +76,7 @@ module Zakuro
|
|
72
76
|
# @return [Integer] 日数
|
73
77
|
#
|
74
78
|
def days
|
75
|
-
@
|
79
|
+
@month_label.days
|
76
80
|
end
|
77
81
|
|
78
82
|
#
|
@@ -81,31 +85,96 @@ module Zakuro
|
|
81
85
|
# @return [String] 月の名前(大小)
|
82
86
|
#
|
83
87
|
def days_name
|
84
|
-
@
|
88
|
+
@month_label.days_name
|
85
89
|
end
|
86
90
|
|
87
91
|
#
|
88
|
-
#
|
92
|
+
# 月を返す
|
89
93
|
#
|
90
|
-
# @
|
94
|
+
# @return [Integer] 月(xx月のxx)
|
91
95
|
#
|
92
|
-
|
93
|
-
|
96
|
+
def number
|
97
|
+
@month_label.number
|
98
|
+
end
|
99
|
+
|
94
100
|
#
|
95
|
-
|
96
|
-
|
101
|
+
# 閏を返す
|
102
|
+
#
|
103
|
+
# @return [True] 閏月
|
104
|
+
# @return [False] 平月
|
105
|
+
#
|
106
|
+
def leaped?
|
107
|
+
@month_label.leaped
|
108
|
+
end
|
109
|
+
|
110
|
+
#
|
111
|
+
# 次月の大余から月の日数を定める
|
112
|
+
#
|
113
|
+
# @param [Integer] next_month_day 次月の大余
|
114
|
+
#
|
115
|
+
def eval_many_days(next_month_day:)
|
116
|
+
is_many_days = remainder.same_remainder_divided_by_ten?(other: next_month_day)
|
117
|
+
|
118
|
+
@month_label = MonthLabel.new(
|
119
|
+
number: number, is_many_days: is_many_days, leaped: leaped?
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
#
|
124
|
+
# 二十四節気が未設定かどうかを検証する
|
125
|
+
#
|
126
|
+
# @return [True] 設定なし
|
127
|
+
# @return [False] 設定あり
|
128
|
+
#
|
129
|
+
def empty_solar_term?
|
130
|
+
@solar_terms.empty?
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# 中気を返す
|
135
|
+
#
|
136
|
+
# @return [SolarTerm] 中気
|
137
|
+
#
|
138
|
+
def even_term
|
139
|
+
@solar_terms.each do |term|
|
140
|
+
return term if term.index.even?
|
141
|
+
end
|
142
|
+
|
143
|
+
SolarTerm.new
|
144
|
+
end
|
145
|
+
|
146
|
+
#
|
147
|
+
# 節気を返す
|
148
|
+
#
|
149
|
+
# @return [SolarTerm] 節気
|
150
|
+
#
|
151
|
+
def odd_term
|
152
|
+
@solar_terms.each do |term|
|
153
|
+
return term if term.index.odd?
|
154
|
+
end
|
155
|
+
|
156
|
+
SolarTerm.new
|
97
157
|
end
|
98
158
|
|
99
159
|
#
|
100
|
-
#
|
160
|
+
# 二十四節気を追加する
|
101
161
|
#
|
102
|
-
# @
|
162
|
+
# @param [SolarTerm] term 二十四節気
|
103
163
|
#
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
164
|
+
def add_term(term:)
|
165
|
+
@solar_terms.push(term)
|
166
|
+
end
|
167
|
+
|
168
|
+
#
|
169
|
+
# 同一の月情報かを検証する
|
170
|
+
#
|
171
|
+
# @param [Month] other 他の月情報
|
172
|
+
#
|
173
|
+
# @return [True] 同一の月
|
174
|
+
# @return [False] 異なる月
|
175
|
+
#
|
176
|
+
def same?(other:)
|
177
|
+
number == other.number && leaped? == other.leaped?
|
109
178
|
end
|
110
179
|
end
|
111
180
|
end
|