zakuro 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +85 -43
- 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 +73 -0
- data/lib/zakuro/era/japan/gengou.rb +106 -0
- data/lib/zakuro/era/japan/gengou/parser.rb +169 -0
- data/lib/zakuro/era/japan/gengou/type.rb +178 -0
- data/lib/zakuro/era/japan/gengou/validator.rb +234 -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/operation/month/parser.rb +277 -0
- data/lib/zakuro/operation/month/type.rb +452 -0
- data/lib/zakuro/operation/month/validator.rb +498 -0
- data/lib/zakuro/operation/operation.rb +45 -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 +17 -15
- data/lib/zakuro/result/core.rb +52 -0
- data/lib/zakuro/result/data.rb +187 -0
- data/lib/zakuro/result/operation.rb +86 -0
- data/lib/zakuro/result/result.rb +37 -0
- data/lib/zakuro/{output → tools}/stringifier.rb +14 -7
- data/lib/zakuro/tools/typeof.rb +33 -0
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/senmyou/base/era.rb +1 -1
- data/lib/zakuro/version/senmyou/base/multi_gengou.rb +1 -1
- data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +13 -1
- data/lib/zakuro/version/senmyou/base/solar_term.rb +10 -0
- data/lib/zakuro/version/senmyou/monthly/first_day.rb +44 -0
- data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +48 -0
- data/lib/zakuro/version/senmyou/monthly/month.rb +127 -68
- data/lib/zakuro/version/senmyou/monthly/month_label.rb +87 -0
- data/lib/zakuro/version/senmyou/monthly/operated_month.rb +167 -0
- data/lib/zakuro/version/senmyou/{summary → range}/annual_range.rb +20 -23
- data/lib/zakuro/version/senmyou/{summary → range}/full_range.rb +102 -2
- data/lib/zakuro/version/senmyou/range/operated_range.rb +105 -0
- data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +163 -0
- data/lib/zakuro/version/senmyou/senmyou.rb +2 -2
- data/lib/zakuro/version/senmyou/{summary/specifier.rb → specifier/single_day_specifier.rb} +13 -14
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +3 -7
- data/lib/zakuro/version/senmyou/summary/single.rb +71 -0
- data/lib/zakuro/version_factory.rb +1 -1
- metadata +35 -11
- data/lib/zakuro/era/japan.rb +0 -664
- data/lib/zakuro/output/result.rb +0 -225
data/lib/zakuro/output/result.rb
DELETED
@@ -1,225 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
require_relative './stringifier'
|
6
|
-
|
7
|
-
# :nodoc:
|
8
|
-
module Zakuro
|
9
|
-
#
|
10
|
-
# Result 演算結果
|
11
|
-
#
|
12
|
-
module Result
|
13
|
-
#
|
14
|
-
# Gengou 元号
|
15
|
-
#
|
16
|
-
class Gengou
|
17
|
-
# @return [String] 元号名
|
18
|
-
attr_reader :name
|
19
|
-
# @return [Integer] 元号年
|
20
|
-
attr_reader :number
|
21
|
-
|
22
|
-
#
|
23
|
-
# 初期化
|
24
|
-
#
|
25
|
-
# @param [String] name 元号名
|
26
|
-
# @param [Integer] number 元号年
|
27
|
-
#
|
28
|
-
def initialize(name:, number:)
|
29
|
-
@name = name
|
30
|
-
@number = number
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
#
|
35
|
-
# Year 年
|
36
|
-
#
|
37
|
-
class Year
|
38
|
-
# @return [Gengou] 元号(1行目)
|
39
|
-
attr_reader :first_gengou
|
40
|
-
# @return [Gengou] 元号(2行目)
|
41
|
-
attr_reader :second_gengou
|
42
|
-
# @return [String] 十干十二支
|
43
|
-
attr_reader :zodiac_name
|
44
|
-
# @return [Integer] 日数
|
45
|
-
attr_reader :total_days
|
46
|
-
|
47
|
-
#
|
48
|
-
# 初期化
|
49
|
-
#
|
50
|
-
# @param [Gengou] first_gengou 元号(1行目)
|
51
|
-
# @param [Gengou] second_gengou 元号(2行目)
|
52
|
-
# @param [String] zodiac_name 十干十二支
|
53
|
-
# @param [Integer] total_days 日数
|
54
|
-
#
|
55
|
-
def initialize(first_gengou:, second_gengou:, zodiac_name:, total_days:)
|
56
|
-
@first_gengou = first_gengou
|
57
|
-
@second_gengou = second_gengou
|
58
|
-
@zodiac_name = zodiac_name
|
59
|
-
@total_days = total_days
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
#
|
64
|
-
# SolarTerm 二十四節気
|
65
|
-
#
|
66
|
-
class SolarTerm
|
67
|
-
# @return [Integer] 連番
|
68
|
-
attr_reader :index
|
69
|
-
# @return [String] 大余小余
|
70
|
-
attr_reader :remainder
|
71
|
-
|
72
|
-
#
|
73
|
-
# 初期化
|
74
|
-
#
|
75
|
-
# @param [Integer] index 連番
|
76
|
-
# @param [String] remainder 大余小余
|
77
|
-
#
|
78
|
-
def initialize(index:, remainder:)
|
79
|
-
@index = index
|
80
|
-
@remainder = remainder
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# :reek:TooManyInstanceVariables { max_instance_variables: 6 }
|
85
|
-
|
86
|
-
#
|
87
|
-
# Month 月
|
88
|
-
#
|
89
|
-
class Month
|
90
|
-
# TODO: days_name -> zodiac_name
|
91
|
-
|
92
|
-
# @return [Integer] 月順(1-12)
|
93
|
-
attr_reader :number
|
94
|
-
# @return [True] 閏月
|
95
|
-
# @return [False] 平月
|
96
|
-
attr_reader :leaped
|
97
|
-
# @return [String] 十干十二支
|
98
|
-
attr_reader :days_name
|
99
|
-
# @return [Day] 月初日データ
|
100
|
-
attr_reader :first_day
|
101
|
-
# @return [SolarTerm] 二十四節気(節気)
|
102
|
-
attr_reader :odd_solar_terms
|
103
|
-
# @return [SolarTerm] 二十四節気(中気)
|
104
|
-
attr_reader :even_solar_terms
|
105
|
-
|
106
|
-
# rubocop:disable Metrics/ParameterLists
|
107
|
-
# :reek:LongParameterList { max_params: 6 }
|
108
|
-
|
109
|
-
#
|
110
|
-
# 初期化
|
111
|
-
#
|
112
|
-
# @param [Integer] number 月順(1-12)
|
113
|
-
# @param [True, False] leaped 閏月/平月
|
114
|
-
# @param [String] days_name 十干十二支
|
115
|
-
# @param [Day] first_day 月初日データ
|
116
|
-
# @param [SolarTerm] odd_solar_terms 二十四節気(節気)
|
117
|
-
# @param [SolarTerm] even_solar_terms 二十四節気(中気)
|
118
|
-
#
|
119
|
-
def initialize(number:, leaped:, days_name:, first_day:,
|
120
|
-
odd_solar_terms:, even_solar_terms:)
|
121
|
-
@number = number
|
122
|
-
@leaped = leaped
|
123
|
-
@days_name = days_name
|
124
|
-
@first_day = first_day
|
125
|
-
@odd_solar_terms = odd_solar_terms
|
126
|
-
@even_solar_terms = even_solar_terms
|
127
|
-
end
|
128
|
-
# rubocop:enable Metrics/ParameterLists
|
129
|
-
end
|
130
|
-
|
131
|
-
#
|
132
|
-
# Day 日
|
133
|
-
#
|
134
|
-
class Day
|
135
|
-
# @return [Integer] 月初日から数えた日(M月d日のdに相当)
|
136
|
-
attr_reader :number
|
137
|
-
# @return [String] 十干十二支
|
138
|
-
attr_reader :zodiac_name
|
139
|
-
# @return [String] 大余小余
|
140
|
-
attr_reader :remainder
|
141
|
-
# @return [String] 年月日
|
142
|
-
attr_reader :western_date
|
143
|
-
|
144
|
-
#
|
145
|
-
# 初期化
|
146
|
-
#
|
147
|
-
# @param [Integer] number 月初日から数えた日(M月d日のdに相当)
|
148
|
-
# @param [String] zodiac_name 十干十二支
|
149
|
-
# @param [String] remainder 大余小余
|
150
|
-
# @param [String] western_date 年月日
|
151
|
-
#
|
152
|
-
def initialize(number:, zodiac_name:, remainder:, western_date:)
|
153
|
-
@number = number
|
154
|
-
@zodiac_name = zodiac_name
|
155
|
-
@remainder = remainder
|
156
|
-
@western_date = western_date
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
#
|
161
|
-
# Core 共通処理
|
162
|
-
#
|
163
|
-
class Core
|
164
|
-
#
|
165
|
-
# 初期化
|
166
|
-
#
|
167
|
-
def initialize(*_args); end
|
168
|
-
|
169
|
-
#
|
170
|
-
# ハッシュ化する
|
171
|
-
#
|
172
|
-
# @return [Hash<String, Object>] ハッシュ
|
173
|
-
#
|
174
|
-
def to_h
|
175
|
-
Stringifier.to_h(obj: self, class_prefix: 'Zakuro::Result')
|
176
|
-
end
|
177
|
-
|
178
|
-
#
|
179
|
-
# JSON化する
|
180
|
-
#
|
181
|
-
# @param [JSON::State] _args 引数( Struct#to_json )
|
182
|
-
#
|
183
|
-
# @return [String] JSON文字列
|
184
|
-
#
|
185
|
-
def to_json(*_args)
|
186
|
-
JSON.generate(to_h)
|
187
|
-
end
|
188
|
-
|
189
|
-
#
|
190
|
-
# JSON(整形)化する
|
191
|
-
#
|
192
|
-
# @return [String] JSON(整形)文字列
|
193
|
-
#
|
194
|
-
def to_pretty_json
|
195
|
-
JSON.pretty_generate(to_h)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
#
|
200
|
-
# SingleDay 1日分情報
|
201
|
-
#
|
202
|
-
class SingleDay < Core
|
203
|
-
# @return [Year] 年
|
204
|
-
attr_reader :year
|
205
|
-
# @return [Month] 月
|
206
|
-
attr_reader :month
|
207
|
-
# @return [Day] 日
|
208
|
-
attr_reader :day
|
209
|
-
|
210
|
-
#
|
211
|
-
# 初期化
|
212
|
-
#
|
213
|
-
# @param [Year] year 年
|
214
|
-
# @param [Month] month 月
|
215
|
-
# @param [Day] day 日
|
216
|
-
#
|
217
|
-
def initialize(year:, month:, day:)
|
218
|
-
super
|
219
|
-
@year = year
|
220
|
-
@month = month
|
221
|
-
@day = day
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|