zakuro 0.0.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +102 -42
- 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/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 +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.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/{gengou → japan/yaml}/set-001-until-south.yaml +0 -0
- data/lib/zakuro/era/{gengou → japan/yaml}/set-002-from-north.yaml +0 -0
- data/lib/zakuro/era/{gengou → japan/yaml}/set-003-modern.yaml +0 -0
- data/lib/zakuro/era/western.rb +1 -1
- data/lib/zakuro/merchant.rb +2 -2
- 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 +7 -4
- data/lib/zakuro/output/logger.rb +50 -47
- data/lib/zakuro/output/response.rb +146 -143
- 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/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 +167 -0
- data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +6 -6
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +103 -152
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +213 -0
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +3 -184
- 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 +3 -3
- metadata +53 -24
- data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
- data/lib/zakuro/cycle/zodiac.rb +0 -103
- data/lib/zakuro/era/japan.rb +0 -664
- data/lib/zakuro/output/result.rb +0 -225
- 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 -205
- data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
- data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -66
- data/lib/zakuro/version/senmyou/base/year.rb +0 -104
- data/lib/zakuro/version/senmyou/monthly/month.rb +0 -122
- data/lib/zakuro/version/senmyou/summary/annual_range.rb +0 -187
- data/lib/zakuro/version/senmyou/summary/full_range.rb +0 -224
- data/lib/zakuro/version/senmyou/summary/specifier.rb +0 -100
@@ -0,0 +1,187 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './core'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
#
|
8
|
+
# Result 演算結果
|
9
|
+
#
|
10
|
+
module Result
|
11
|
+
#
|
12
|
+
# データ部
|
13
|
+
#
|
14
|
+
module Data
|
15
|
+
#
|
16
|
+
# SingleDay 1日
|
17
|
+
#
|
18
|
+
class SingleDay < Core
|
19
|
+
# @return [Year] 年
|
20
|
+
attr_reader :year
|
21
|
+
# @return [Month] 月
|
22
|
+
attr_reader :month
|
23
|
+
# @return [Day] 日
|
24
|
+
attr_reader :day
|
25
|
+
|
26
|
+
#
|
27
|
+
# 初期化
|
28
|
+
#
|
29
|
+
# @param [Year] year 年
|
30
|
+
# @param [Month] month 月
|
31
|
+
# @param [Day] day 日
|
32
|
+
#
|
33
|
+
def initialize(year:, month:, day:)
|
34
|
+
super
|
35
|
+
@year = year
|
36
|
+
@month = month
|
37
|
+
@day = day
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Gengou 元号
|
43
|
+
#
|
44
|
+
class Gengou
|
45
|
+
# @return [String] 元号名
|
46
|
+
attr_reader :name
|
47
|
+
# @return [Integer] 元号年
|
48
|
+
attr_reader :number
|
49
|
+
|
50
|
+
#
|
51
|
+
# 初期化
|
52
|
+
#
|
53
|
+
# @param [String] name 元号名
|
54
|
+
# @param [Integer] number 元号年
|
55
|
+
#
|
56
|
+
def initialize(name: '', number: -1)
|
57
|
+
@name = name
|
58
|
+
@number = number
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Year 年
|
64
|
+
#
|
65
|
+
class Year
|
66
|
+
# @return [Gengou] 元号(1行目)
|
67
|
+
attr_reader :first_gengou
|
68
|
+
# @return [Gengou] 元号(2行目)
|
69
|
+
attr_reader :second_gengou
|
70
|
+
# @return [String] 十干十二支
|
71
|
+
attr_reader :zodiac_name
|
72
|
+
# @return [Integer] 日数
|
73
|
+
attr_reader :total_days
|
74
|
+
|
75
|
+
#
|
76
|
+
# 初期化
|
77
|
+
#
|
78
|
+
# @param [Gengou] first_gengou 元号(1行目)
|
79
|
+
# @param [Gengou] second_gengou 元号(2行目)
|
80
|
+
# @param [String] zodiac_name 十干十二支
|
81
|
+
# @param [Integer] total_days 日数
|
82
|
+
#
|
83
|
+
def initialize(first_gengou:, second_gengou:, zodiac_name:, total_days:)
|
84
|
+
@first_gengou = first_gengou
|
85
|
+
@second_gengou = second_gengou
|
86
|
+
@zodiac_name = zodiac_name
|
87
|
+
@total_days = total_days
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# SolarTerm 二十四節気
|
93
|
+
#
|
94
|
+
class SolarTerm
|
95
|
+
# @return [Integer] 連番
|
96
|
+
attr_reader :index
|
97
|
+
# @return [String] 大余小余
|
98
|
+
attr_reader :remainder
|
99
|
+
|
100
|
+
#
|
101
|
+
# 初期化
|
102
|
+
#
|
103
|
+
# @param [Integer] index 連番
|
104
|
+
# @param [String] remainder 大余小余
|
105
|
+
#
|
106
|
+
def initialize(index:, remainder:)
|
107
|
+
@index = index
|
108
|
+
@remainder = remainder
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# :reek:TooManyInstanceVariables { max_instance_variables: 6 }
|
113
|
+
|
114
|
+
#
|
115
|
+
# Month 月
|
116
|
+
#
|
117
|
+
class Month
|
118
|
+
# @return [Integer] 月順(1-12)
|
119
|
+
attr_reader :number
|
120
|
+
# @return [True] 閏月
|
121
|
+
# @return [False] 平月
|
122
|
+
attr_reader :leaped
|
123
|
+
# @return [String] 月の大小
|
124
|
+
attr_reader :days_name
|
125
|
+
# @return [Day] 月初日データ
|
126
|
+
attr_reader :first_day
|
127
|
+
# @return [SolarTerm] 二十四節気(節気)
|
128
|
+
attr_reader :odd_solar_terms
|
129
|
+
# @return [SolarTerm] 二十四節気(中気)
|
130
|
+
attr_reader :even_solar_terms
|
131
|
+
|
132
|
+
# rubocop:disable Metrics/ParameterLists
|
133
|
+
# :reek:LongParameterList { max_params: 6 }
|
134
|
+
|
135
|
+
#
|
136
|
+
# 初期化
|
137
|
+
#
|
138
|
+
# @param [Integer] number 月順(1-12)
|
139
|
+
# @param [True, False] leaped 閏月/平月
|
140
|
+
# @param [String] days_name 月の大小
|
141
|
+
# @param [Day] first_day 月初日データ
|
142
|
+
# @param [SolarTerm] odd_solar_terms 二十四節気(節気)
|
143
|
+
# @param [SolarTerm] even_solar_terms 二十四節気(中気)
|
144
|
+
#
|
145
|
+
def initialize(number:, leaped:, days_name:, first_day:,
|
146
|
+
odd_solar_terms:, even_solar_terms:)
|
147
|
+
@number = number
|
148
|
+
@leaped = leaped
|
149
|
+
@days_name = days_name
|
150
|
+
@first_day = first_day
|
151
|
+
@odd_solar_terms = odd_solar_terms
|
152
|
+
@even_solar_terms = even_solar_terms
|
153
|
+
end
|
154
|
+
# rubocop:enable Metrics/ParameterLists
|
155
|
+
end
|
156
|
+
|
157
|
+
#
|
158
|
+
# Day 日
|
159
|
+
#
|
160
|
+
class Day
|
161
|
+
# @return [Integer] 月初日から数えた日(M月d日のdに相当)
|
162
|
+
attr_reader :number
|
163
|
+
# @return [String] 十干十二支
|
164
|
+
attr_reader :zodiac_name
|
165
|
+
# @return [String] 大余小余
|
166
|
+
attr_reader :remainder
|
167
|
+
# @return [String] 年月日
|
168
|
+
attr_reader :western_date
|
169
|
+
|
170
|
+
#
|
171
|
+
# 初期化
|
172
|
+
#
|
173
|
+
# @param [Integer] number 月初日から数えた日(M月d日のdに相当)
|
174
|
+
# @param [String] zodiac_name 十干十二支
|
175
|
+
# @param [String] remainder 大余小余
|
176
|
+
# @param [String] western_date 年月日
|
177
|
+
#
|
178
|
+
def initialize(number:, zodiac_name:, remainder:, western_date:)
|
179
|
+
@number = number
|
180
|
+
@zodiac_name = zodiac_name
|
181
|
+
@remainder = remainder
|
182
|
+
@western_date = western_date
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nodoc:
|
4
|
+
module Zakuro
|
5
|
+
#
|
6
|
+
# Result 演算結果
|
7
|
+
#
|
8
|
+
module Result
|
9
|
+
#
|
10
|
+
# 運用情報
|
11
|
+
#
|
12
|
+
module Operation
|
13
|
+
#
|
14
|
+
# Bundle 運用情報
|
15
|
+
#
|
16
|
+
class Bundle
|
17
|
+
# @return [True] 運用あり
|
18
|
+
# @return [False] 運用なし
|
19
|
+
attr_reader :operated
|
20
|
+
# @return [Month::Bundle] 月別履歴情報
|
21
|
+
attr_reader :month
|
22
|
+
# @return [Data::SingleDay] 計算値
|
23
|
+
attr_reader :original
|
24
|
+
|
25
|
+
#
|
26
|
+
# 初期化
|
27
|
+
#
|
28
|
+
# @param [True, False] operated 運用有無
|
29
|
+
# @param [Month::Bundle] month 月別履歴情報
|
30
|
+
# @param [Data::SingleDay] original 計算値
|
31
|
+
#
|
32
|
+
def initialize(operated:, month:, original:)
|
33
|
+
@operated = operated
|
34
|
+
@month = month
|
35
|
+
@original = original
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Month 運用情報(月)
|
41
|
+
#
|
42
|
+
module Month
|
43
|
+
#
|
44
|
+
# Bundle 月履歴集約情報
|
45
|
+
#
|
46
|
+
class Bundle
|
47
|
+
# @return [History] 月別履歴情報(当月)
|
48
|
+
attr_reader :current
|
49
|
+
# @return [History] 月別履歴情報(影響を与えた月)
|
50
|
+
attr_reader :parent
|
51
|
+
|
52
|
+
def initialize(current: History.new, parent: History.new)
|
53
|
+
@current = current
|
54
|
+
@parent = parent
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# History 月別履歴情報
|
60
|
+
#
|
61
|
+
class History
|
62
|
+
# @return [String] ID
|
63
|
+
attr_reader :id
|
64
|
+
# @return [String] 月初日の西暦日
|
65
|
+
attr_reader :western_date
|
66
|
+
# @return [Integer] 原文頁数
|
67
|
+
attr_reader :page
|
68
|
+
# @return [Integer] 原文注釈番号
|
69
|
+
attr_reader :number
|
70
|
+
# @return [Array<Zakuro::Result::Operation::Annotation>] 注釈
|
71
|
+
attr_reader :annotations
|
72
|
+
|
73
|
+
#
|
74
|
+
# 初期化
|
75
|
+
#
|
76
|
+
# @param [String] id ID
|
77
|
+
# @param [String] western_date 月初日の西暦日
|
78
|
+
# @param [Integer] page 原文頁数
|
79
|
+
# @param [Integer] number 原文注釈番号
|
80
|
+
# @param [Array<Annotation>] annotations 注釈
|
81
|
+
#
|
82
|
+
def initialize(id: '', western_date: '', page: -1, number: -1, annotations: [])
|
83
|
+
@id = id
|
84
|
+
@western_date = western_date
|
85
|
+
@page = page
|
86
|
+
@number = number
|
87
|
+
@annotations = annotations
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# Annotation 注釈
|
93
|
+
#
|
94
|
+
class Annotation
|
95
|
+
# @return [String] 注釈内容
|
96
|
+
attr_reader :description
|
97
|
+
# @return [String] 注釈補記
|
98
|
+
attr_reader :note
|
99
|
+
|
100
|
+
#
|
101
|
+
# 初期化
|
102
|
+
#
|
103
|
+
# @param [String] description 注釈内容
|
104
|
+
# @param [<Type>] note 注釈補記
|
105
|
+
#
|
106
|
+
def initialize(description:, note:)
|
107
|
+
@description = description
|
108
|
+
@note = note
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
require_relative './core'
|
6
|
+
require_relative './data'
|
7
|
+
require_relative './operation'
|
8
|
+
|
9
|
+
# :nodoc:
|
10
|
+
module Zakuro
|
11
|
+
#
|
12
|
+
# Result 演算結果
|
13
|
+
#
|
14
|
+
module Result
|
15
|
+
#
|
16
|
+
# Single 1日検索結果
|
17
|
+
#
|
18
|
+
class Single < Core
|
19
|
+
# @return [Data::SingleDay] 1日
|
20
|
+
attr_reader :data
|
21
|
+
# @return [Operation::Bundle] 運用情報
|
22
|
+
attr_reader :operation
|
23
|
+
|
24
|
+
#
|
25
|
+
# 初期化
|
26
|
+
#
|
27
|
+
# @param [Data::SingleDay] data 1日
|
28
|
+
# @param [Operation::Bundle] operation 運用情報
|
29
|
+
#
|
30
|
+
def initialize(data:, operation:)
|
31
|
+
super
|
32
|
+
@data = data
|
33
|
+
@operation = operation
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './typeof'
|
4
|
+
|
3
5
|
# :nodoc:
|
4
6
|
module Zakuro
|
5
7
|
#
|
6
|
-
#
|
8
|
+
# Tools 汎用メソッド群
|
7
9
|
#
|
8
|
-
module
|
10
|
+
module Tools
|
9
11
|
#
|
10
12
|
# Stringifier 文字列処理
|
11
13
|
#
|
@@ -18,16 +20,18 @@ module Zakuro
|
|
18
20
|
#
|
19
21
|
# @return [Hash<String, Objcet>] ハッシュ
|
20
22
|
#
|
21
|
-
def self.to_h(obj:, class_prefix:)
|
23
|
+
def self.to_h(obj:, class_prefix:, formatted: true)
|
22
24
|
hash = {}
|
23
25
|
obj.instance_variables.each do |var|
|
24
26
|
key = var.to_s.delete('@')
|
25
|
-
hash[key] = value_to_hash(
|
27
|
+
hash[key] = value_to_hash(
|
28
|
+
obj: obj.instance_variable_get(var), class_prefix: class_prefix, formatted: formatted
|
29
|
+
)
|
26
30
|
end
|
27
31
|
hash
|
28
32
|
end
|
29
33
|
|
30
|
-
# :reek:TooManyStatements { max_statements: 7 }
|
34
|
+
# :reek:TooManyStatements { max_statements: 7 }
|
31
35
|
|
32
36
|
#
|
33
37
|
# 対象インスタンスをハッシュ化する(再帰処理)
|
@@ -37,19 +41,22 @@ module Zakuro
|
|
37
41
|
#
|
38
42
|
# @return [Hash<String, Objcet>] ハッシュ
|
39
43
|
#
|
40
|
-
def self.value_to_hash(obj:, class_prefix:)
|
41
|
-
return obj
|
44
|
+
def self.value_to_hash(obj:, class_prefix:, formatted:)
|
45
|
+
return obj unless obj
|
46
|
+
|
47
|
+
# 日付をフォーマットする
|
48
|
+
return obj.format if formatted && Tools::Typeof.time?(obj: obj)
|
42
49
|
|
43
50
|
# 同じモジュール内のオブジェクトは再帰する
|
44
51
|
if obj.class.name.start_with?(class_prefix)
|
45
|
-
return to_h(obj: obj, class_prefix: class_prefix)
|
52
|
+
return to_h(obj: obj, class_prefix: class_prefix, formatted: formatted)
|
46
53
|
end
|
47
54
|
|
48
55
|
# 配列は要素一つずつで再帰する
|
49
56
|
if obj.is_a?(Array)
|
50
57
|
arr = []
|
51
58
|
obj.each do |item|
|
52
|
-
arr.push(to_h(obj: item, class_prefix: class_prefix))
|
59
|
+
arr.push(to_h(obj: item, class_prefix: class_prefix, formatted: formatted))
|
53
60
|
end
|
54
61
|
return arr
|
55
62
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../calculation/cycle/abstract_remainder'
|
4
|
+
require_relative '../era/western'
|
5
|
+
|
6
|
+
# :nodoc:
|
7
|
+
module Zakuro
|
8
|
+
#
|
9
|
+
# Tools 汎用メソッド群
|
10
|
+
#
|
11
|
+
module Tools
|
12
|
+
#
|
13
|
+
# Typeof 型判定
|
14
|
+
#
|
15
|
+
module Typeof
|
16
|
+
#
|
17
|
+
# 時間を表す型か
|
18
|
+
#
|
19
|
+
# @param [Object] obj 引数
|
20
|
+
#
|
21
|
+
# @return [True] 時間型である
|
22
|
+
# @return [False] 時間型ではない
|
23
|
+
#
|
24
|
+
def self.time?(obj:)
|
25
|
+
return true if obj.is_a?(Western::Calendar)
|
26
|
+
|
27
|
+
return true if obj.is_a?(Calculation::Cycle::AbstractRemainder)
|
28
|
+
|
29
|
+
false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/zakuro/version.rb
CHANGED