zakuro 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +3 -0
- data/README.md +22 -7
- data/VERSION +1 -0
- data/doc/operation/transfer.rb +8 -8
- data/lib/zakuro/calculation/base/gengou.rb +128 -0
- data/lib/zakuro/calculation/base/linear_gengou.rb +76 -0
- data/lib/zakuro/calculation/base/operated_year.rb +5 -15
- data/lib/zakuro/calculation/base/year.rb +26 -14
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +209 -0
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
- data/lib/zakuro/calculation/era/gengou/internal/connector.rb +107 -0
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +214 -0
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +104 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +230 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +193 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +158 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +75 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +41 -0
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +51 -0
- data/lib/zakuro/calculation/era/version/internal/range.rb +39 -0
- data/lib/zakuro/calculation/era/version/version.rb +24 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
- data/lib/zakuro/calculation/monthly/month.rb +88 -2
- data/lib/zakuro/calculation/monthly/operated_month.rb +3 -3
- data/lib/zakuro/calculation/range/abstract_full_range.rb +172 -0
- data/lib/zakuro/calculation/range/{operated_range.rb → abstract_operation_range.rb} +17 -15
- data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
- data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
- data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
- data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -19
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +54 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +25 -21
- data/lib/zakuro/calculation/summary/internal/month.rb +84 -0
- data/lib/zakuro/calculation/summary/{single.rb → internal/operation.rb} +6 -37
- data/lib/zakuro/calculation/summary/japan/range.rb +152 -0
- data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +91 -0
- data/lib/zakuro/calculation/summary/western/range.rb +124 -0
- data/lib/zakuro/calculation/summary/western/single.rb +113 -0
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +169 -0
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +93 -0
- data/lib/zakuro/condition.rb +15 -2
- data/lib/zakuro/era/japan/calendar.rb +133 -0
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +121 -0
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +168 -0
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +175 -0
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +187 -0
- data/lib/zakuro/era/japan/gengou/alignment.rb +55 -0
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +243 -0
- data/lib/zakuro/era/japan/gengou/resource/type.rb +293 -0
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +347 -0
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +1870 -0
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml +810 -0
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml +50 -0
- data/lib/zakuro/era/japan/gengou/resource.rb +33 -0
- data/lib/zakuro/era/japan/gengou.rb +26 -80
- data/lib/zakuro/era/japan/version.rb +151 -0
- data/lib/zakuro/era/{western.rb → western/calendar.rb} +9 -9
- data/lib/zakuro/exception/case/pattern.rb +35 -0
- data/lib/zakuro/exception/case/preset.rb +51 -0
- data/lib/zakuro/exception/case/template.rb +48 -0
- data/lib/zakuro/exception/cause.rb +28 -0
- data/lib/zakuro/exception/exception.rb +37 -0
- data/lib/zakuro/exception/zakuro_error.rb +28 -0
- data/lib/zakuro/gateway/locale/date.rb +127 -0
- data/lib/zakuro/gateway/locale/range.rb +67 -0
- data/lib/zakuro/gateway/range.rb +99 -0
- data/lib/zakuro/gateway/single.rb +70 -0
- data/lib/zakuro/merchant.rb +15 -4
- data/lib/zakuro/operation/month/parser.rb +10 -10
- data/lib/zakuro/operation/month/type.rb +32 -32
- data/lib/zakuro/operation/month/validator.rb +51 -51
- data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
- data/lib/zakuro/output/logger.rb +17 -3
- data/lib/zakuro/output/response.rb +5 -5
- data/lib/zakuro/result/data/day.rb +43 -0
- data/lib/zakuro/result/data/gengou.rb +35 -0
- data/lib/zakuro/result/data/month.rb +63 -0
- data/lib/zakuro/result/data/single_day.rb +48 -0
- data/lib/zakuro/result/data/solar_term.rb +35 -0
- data/lib/zakuro/result/data/year.rb +45 -0
- data/lib/zakuro/result/operation/month/annotation.rb +40 -0
- data/lib/zakuro/result/operation/month/bundle.rb +36 -0
- data/lib/zakuro/result/operation/month/history.rb +54 -0
- data/lib/zakuro/result/operation/operation.rb +44 -0
- data/lib/zakuro/result/result.rb +21 -2
- data/lib/zakuro/tools/typeconv.rb +38 -0
- data/lib/zakuro/tools/typeof.rb +4 -1
- data/lib/zakuro/version/context.rb +24 -3
- data/lib/zakuro/version/daien/daien.rb +1 -26
- data/lib/zakuro/version/genka/genka.rb +1 -26
- data/lib/zakuro/version/gihou/gihou.rb +1 -30
- data/lib/zakuro/version/gregorio/gregorio.rb +1 -9
- data/lib/zakuro/version/houryaku/houryaku.rb +1 -9
- data/lib/zakuro/version/joukyou/joukyou.rb +1 -9
- data/lib/zakuro/version/kansei/kansei.rb +1 -9
- data/lib/zakuro/version/senmyou/README.md +11 -7
- data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
- data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
- data/zakuro.gemspec +1 -3
- metadata +74 -22
- data/lib/zakuro/calculation/base/multi_gengou.rb +0 -101
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +0 -218
- data/lib/zakuro/calculation/range/full_range.rb +0 -210
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
- data/lib/zakuro/calculation/specifier/single_day.rb +0 -109
- data/lib/zakuro/era/japan/gengou/parser.rb +0 -167
- data/lib/zakuro/era/japan/gengou/type.rb +0 -178
- data/lib/zakuro/era/japan/gengou/validator.rb +0 -236
- data/lib/zakuro/era/japan/reki.rb +0 -91
- data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +0 -1121
- data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +0 -485
- data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +0 -28
- data/lib/zakuro/result/data.rb +0 -187
- data/lib/zakuro/result/operation.rb +0 -114
- data/lib/zakuro/version/abstract_version.rb +0 -29
- data/lib/zakuro/version.rb +0 -7
- data/lib/zakuro/version_factory.rb +0 -59
@@ -0,0 +1,127 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../era/japan/calendar'
|
4
|
+
require_relative '../../era/western/calendar'
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
# :nodoc:
|
9
|
+
module Zakuro
|
10
|
+
# :nodoc:
|
11
|
+
module Gateway
|
12
|
+
# :nodoc:
|
13
|
+
class Locale
|
14
|
+
#
|
15
|
+
# Date 日付
|
16
|
+
#
|
17
|
+
class Date
|
18
|
+
INDALID = Object::Date.new
|
19
|
+
|
20
|
+
# @return [Western::Calendar] 西暦日
|
21
|
+
attr_reader :western_date
|
22
|
+
# @return [Japan::Calendar] 和暦日
|
23
|
+
attr_reader :japan_date
|
24
|
+
|
25
|
+
#
|
26
|
+
# 初期化
|
27
|
+
#
|
28
|
+
# @param [Date, String] date 日付
|
29
|
+
#
|
30
|
+
def initialize(date: INDALID)
|
31
|
+
@western_date = Western::Calendar.new
|
32
|
+
@japan_date = Japan::Calendar.new
|
33
|
+
|
34
|
+
parse(date: date)
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# 和暦日が有効か
|
39
|
+
#
|
40
|
+
# @return [True] 有効
|
41
|
+
# @return [False] 無効
|
42
|
+
#
|
43
|
+
def valid_japan?
|
44
|
+
!invalid_japan?
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# 和暦日が不正か
|
49
|
+
#
|
50
|
+
# @return [True] 不正
|
51
|
+
# @return [False] 不正なし
|
52
|
+
#
|
53
|
+
def invalid_japan?
|
54
|
+
@japan_date.invalid?
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# 西暦日が有効か
|
59
|
+
#
|
60
|
+
# @return [True] 有効
|
61
|
+
# @return [False] 無効
|
62
|
+
#
|
63
|
+
def valid_western?
|
64
|
+
!invalid_western?
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# 西暦日が不正か
|
69
|
+
#
|
70
|
+
# @return [True] 不正
|
71
|
+
# @return [False] 不正なし
|
72
|
+
#
|
73
|
+
def invalid_western?
|
74
|
+
@western_date.invalid?
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# 不正か
|
79
|
+
#
|
80
|
+
# @return [True] 不正
|
81
|
+
# @return [False] 不正なし
|
82
|
+
#
|
83
|
+
def invalid?
|
84
|
+
invalid_japan? && invalid_western?
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
#
|
90
|
+
# 解析する
|
91
|
+
#
|
92
|
+
# @param [Date, String] date 日付
|
93
|
+
#
|
94
|
+
def parse(date:)
|
95
|
+
return unless date
|
96
|
+
|
97
|
+
return if date == INDALID
|
98
|
+
|
99
|
+
if date.is_a?(Object::Date)
|
100
|
+
@western_date = Western::Calendar.create(date: date)
|
101
|
+
return
|
102
|
+
end
|
103
|
+
|
104
|
+
return unless date.is_a?(String)
|
105
|
+
|
106
|
+
parse_text(text: date)
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# 文字解析する
|
111
|
+
#
|
112
|
+
# @param [String] text 日付文字列
|
113
|
+
#
|
114
|
+
def parse_text(text:)
|
115
|
+
if Western::Calendar.valid_date_string(text: text)
|
116
|
+
@western_date = Western::Calendar.parse(text: text)
|
117
|
+
return
|
118
|
+
end
|
119
|
+
|
120
|
+
return unless Japan::Calendar.valid_date_string(text: text)
|
121
|
+
|
122
|
+
@japan_date = Japan::Calendar.parse(text: text)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './date'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Gateway
|
9
|
+
# :nodoc:
|
10
|
+
class Locale
|
11
|
+
#
|
12
|
+
# Range 範囲
|
13
|
+
#
|
14
|
+
class Range
|
15
|
+
# @return [LocaleDate] 開始日
|
16
|
+
attr_reader :start_date
|
17
|
+
# @return [LocaleDate] 終了日
|
18
|
+
attr_reader :last_date
|
19
|
+
|
20
|
+
#
|
21
|
+
# 初期化
|
22
|
+
#
|
23
|
+
# @param [Hash<Symbol, Object>] range 範囲
|
24
|
+
#
|
25
|
+
def initialize(range:)
|
26
|
+
@start_date = Date.new
|
27
|
+
@last_date = Date.new
|
28
|
+
|
29
|
+
return unless range
|
30
|
+
|
31
|
+
@start_date = Date.new(date: range[:start])
|
32
|
+
@last_date = Date.new(date: range[:last])
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# 西暦日は有効か
|
37
|
+
#
|
38
|
+
# @return [True] 有効
|
39
|
+
# @return [False] 無効
|
40
|
+
#
|
41
|
+
def valid_western?
|
42
|
+
@start_date.valid_western? && @last_date.valid_western?
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# 和暦日は有効か
|
47
|
+
#
|
48
|
+
# @return [True] 有効
|
49
|
+
# @return [False] 無効
|
50
|
+
#
|
51
|
+
def valid_japan?
|
52
|
+
@start_date.valid_japan? && @last_date.valid_japan?
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# 不正か
|
57
|
+
#
|
58
|
+
# @return [True] 不正
|
59
|
+
# @return [False] 不正なし
|
60
|
+
#
|
61
|
+
def invalid?
|
62
|
+
@start_date.invalid? && @last_date.invalid?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../calculation/summary/japan/range'
|
4
|
+
require_relative '../calculation/summary/western/range'
|
5
|
+
require_relative '../exception/case/preset'
|
6
|
+
require_relative '../exception/exception'
|
7
|
+
|
8
|
+
require_relative './locale/range'
|
9
|
+
|
10
|
+
# :nodoc:
|
11
|
+
module Zakuro
|
12
|
+
# :nodoc:
|
13
|
+
module Gateway
|
14
|
+
#
|
15
|
+
# Range 範囲
|
16
|
+
#
|
17
|
+
class Range
|
18
|
+
# @return [Context] 暦コンテキスト
|
19
|
+
attr_reader :context
|
20
|
+
# @return [Locale::Range] 範囲
|
21
|
+
attr_reader :range
|
22
|
+
|
23
|
+
#
|
24
|
+
# 初期化
|
25
|
+
#
|
26
|
+
# @param [Context] context 暦コンテキスト
|
27
|
+
# @param [Hash<Symbol, Object>] range 範囲
|
28
|
+
#
|
29
|
+
def initialize(context:, range:)
|
30
|
+
@context = context
|
31
|
+
@range = Locale::Range.new(range: range)
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# 不正か
|
36
|
+
#
|
37
|
+
# @return [True] 不正
|
38
|
+
# @return [False] 不正なし
|
39
|
+
#
|
40
|
+
def invalid?
|
41
|
+
@range.invalid?
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# 検索結果を取得する
|
46
|
+
#
|
47
|
+
# @return [Result::Range] 範囲検索結果(和暦日)
|
48
|
+
#
|
49
|
+
def get
|
50
|
+
start_date = range.start_date
|
51
|
+
last_date = range.last_date
|
52
|
+
|
53
|
+
return western(start_date: start_date, last_date: last_date) if range.valid_western?
|
54
|
+
|
55
|
+
return japan(start_date: start_date, last_date: last_date) if range.valid_japan?
|
56
|
+
|
57
|
+
raise Exception.get(
|
58
|
+
presets: [
|
59
|
+
Exception::Case::Preset.new(
|
60
|
+
template: Exception::Case::Pattern::INVALID_RANGE
|
61
|
+
)
|
62
|
+
]
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
#
|
69
|
+
# 西暦日による結果を取得する
|
70
|
+
#
|
71
|
+
# @param [Locale::Date] start_date 西暦開始日
|
72
|
+
# @param [Locale::Date] last_date 西暦終了日
|
73
|
+
#
|
74
|
+
# @return [Result::Range] 範囲検索結果(和暦日)
|
75
|
+
#
|
76
|
+
def western(start_date: Locale::Date.new, last_date: Locale::Date.new)
|
77
|
+
Calculation::Summary::Western::Range.get(
|
78
|
+
context: context, start_date: start_date.western_date,
|
79
|
+
last_date: last_date.western_date
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# 和暦日による結果を取得する
|
85
|
+
#
|
86
|
+
# @param [Locale::Date] start_date 和暦開始日
|
87
|
+
# @param [Locale::Date] last_date 和暦終了日
|
88
|
+
#
|
89
|
+
# @return [Result::Range] 範囲検索結果(和暦日)
|
90
|
+
#
|
91
|
+
def japan(start_date: Locale::Date.new, last_date: Locale::Date.new)
|
92
|
+
Calculation::Summary::Japan::Range.get(
|
93
|
+
context: context, start_date: start_date.japan_date,
|
94
|
+
last_date: last_date.japan_date
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../calculation/summary/japan/single'
|
4
|
+
require_relative '../calculation/summary/western/single'
|
5
|
+
require_relative '../exception/case/preset'
|
6
|
+
require_relative '../exception/exception'
|
7
|
+
|
8
|
+
require_relative './locale/date'
|
9
|
+
|
10
|
+
# :nodoc:
|
11
|
+
module Zakuro
|
12
|
+
# :nodoc:
|
13
|
+
module Gateway
|
14
|
+
#
|
15
|
+
# Single 1日
|
16
|
+
#
|
17
|
+
class Single
|
18
|
+
# @return [Locale::Date] 日付
|
19
|
+
attr_reader :date
|
20
|
+
|
21
|
+
#
|
22
|
+
# 初期化
|
23
|
+
#
|
24
|
+
# @param [Context] context 暦コンテキスト
|
25
|
+
# @param [Date, String] date 日付
|
26
|
+
#
|
27
|
+
def initialize(context:, date:)
|
28
|
+
@context = context
|
29
|
+
@date = Locale::Date.new(date: date)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# 不正か
|
34
|
+
#
|
35
|
+
# @return [True] 不正
|
36
|
+
# @return [False] 不正なし
|
37
|
+
#
|
38
|
+
def invalid?
|
39
|
+
@date.invalid?
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# 検索結果を取得する
|
44
|
+
#
|
45
|
+
# @return [Result::Single] 一日検索結果(和暦日)
|
46
|
+
#
|
47
|
+
def get
|
48
|
+
if date.valid_western?
|
49
|
+
return Calculation::Summary::Western::Single.get(
|
50
|
+
context: @context, date: date.western_date
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
if date.valid_japan?
|
55
|
+
return Calculation::Summary::Japan::Single.get(
|
56
|
+
context: @context, date: date.japan_date
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
raise Exception.get(
|
61
|
+
presets: [
|
62
|
+
Exception::Case::Preset.new(
|
63
|
+
template: Exception::Case::Pattern::INVALID_DATE
|
64
|
+
)
|
65
|
+
]
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/zakuro/merchant.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative './
|
3
|
+
require_relative './gateway/single'
|
4
|
+
|
5
|
+
require_relative './gateway/range'
|
6
|
+
|
4
7
|
require_relative './condition'
|
5
8
|
|
6
9
|
require_relative './output/error'
|
@@ -47,12 +50,20 @@ module Zakuro
|
|
47
50
|
# 承諾する
|
48
51
|
#
|
49
52
|
# @return [Result::SingleDay] 和暦日
|
53
|
+
# @return [Result::Range] 和暦日範囲
|
50
54
|
#
|
51
55
|
def commit
|
52
|
-
|
53
|
-
|
56
|
+
# TODO: condition で設定する
|
57
|
+
context = Context.new(version_name: '')
|
58
|
+
|
59
|
+
single = Gateway::Single.new(context: context, date: condition.date)
|
60
|
+
|
61
|
+
return single.get unless single.invalid?
|
62
|
+
|
63
|
+
range = Gateway::Range.new(context: context, range: condition.range)
|
64
|
+
|
65
|
+
return range.get unless range.invalid?
|
54
66
|
|
55
|
-
# TODO: does not have no patterns now
|
56
67
|
{}
|
57
68
|
end
|
58
69
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
-
require_relative '../../era/western'
|
4
|
+
require_relative '../../era/western/calendar'
|
5
5
|
require_relative './validator'
|
6
6
|
require_relative './type'
|
7
7
|
|
@@ -80,7 +80,7 @@ module Zakuro
|
|
80
80
|
def self.western_date(str:)
|
81
81
|
return Western::Calendar.new if invalid?(str: str)
|
82
82
|
|
83
|
-
Western::Calendar.parse(
|
83
|
+
Western::Calendar.parse(text: str)
|
84
84
|
end
|
85
85
|
|
86
86
|
#
|
@@ -311,8 +311,8 @@ module Zakuro
|
|
311
311
|
|
312
312
|
def self.create_solar_term(yaml_hash: {})
|
313
313
|
SolarTerm::Direction.new(
|
314
|
-
source: create_source_solar_term(yaml_hash: yaml_hash['
|
315
|
-
destination: create_destination_solar_term(yaml_hash: yaml_hash['
|
314
|
+
source: create_source_solar_term(yaml_hash: yaml_hash['src']),
|
315
|
+
destination: create_destination_solar_term(yaml_hash: yaml_hash['dest']),
|
316
316
|
days: Operation::TypeParser.days(str: yaml_hash['days'])
|
317
317
|
)
|
318
318
|
end
|
@@ -347,24 +347,24 @@ module Zakuro
|
|
347
347
|
|
348
348
|
def self.create_month_number(yaml_hash: {})
|
349
349
|
Number.new(
|
350
|
-
|
351
|
-
|
350
|
+
src: Operation::TypeParser.month_number(str: yaml_hash['src']),
|
351
|
+
dest: Operation::TypeParser.month_number(str: yaml_hash['dest'])
|
352
352
|
)
|
353
353
|
end
|
354
354
|
private_class_method :create_month_number
|
355
355
|
|
356
356
|
def self.create_month_leaped(yaml_hash: {})
|
357
357
|
Leaped.new(
|
358
|
-
|
359
|
-
|
358
|
+
src: Operation::TypeParser.month_leaped(str: yaml_hash['src']),
|
359
|
+
dest: Operation::TypeParser.month_leaped(str: yaml_hash['dest'])
|
360
360
|
)
|
361
361
|
end
|
362
362
|
private_class_method :create_month_leaped
|
363
363
|
|
364
364
|
def self.create_month_day(yaml_hash: {})
|
365
365
|
Days.new(
|
366
|
-
|
367
|
-
|
366
|
+
src: yaml_hash['src'],
|
367
|
+
dest: yaml_hash['dest']
|
368
368
|
)
|
369
369
|
end
|
370
370
|
private_class_method :create_month_day
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
-
require_relative '../../era/western'
|
4
|
+
require_relative '../../era/western/calendar'
|
5
5
|
require_relative './validator'
|
6
6
|
|
7
7
|
# :nodoc:
|
@@ -339,20 +339,20 @@ module Zakuro
|
|
339
339
|
# Number 月
|
340
340
|
#
|
341
341
|
class Number
|
342
|
-
# @return [Integer]
|
343
|
-
attr_reader :
|
344
|
-
# @return [Integer]
|
345
|
-
attr_reader :
|
342
|
+
# @return [Integer] 移動もと
|
343
|
+
attr_reader :src
|
344
|
+
# @return [Integer] 移動先
|
345
|
+
attr_reader :dest
|
346
346
|
|
347
347
|
#
|
348
348
|
# 初期化
|
349
349
|
#
|
350
|
-
# @param [Integer]
|
351
|
-
# @param [Integer]
|
350
|
+
# @param [Integer] src 移動元
|
351
|
+
# @param [Integer] dest 移動先
|
352
352
|
#
|
353
|
-
def initialize(
|
354
|
-
@
|
355
|
-
@
|
353
|
+
def initialize(src: -1, dest: -1)
|
354
|
+
@src = src
|
355
|
+
@dest = dest
|
356
356
|
end
|
357
357
|
|
358
358
|
#
|
@@ -362,7 +362,7 @@ module Zakuro
|
|
362
362
|
# @return [False] 有効
|
363
363
|
#
|
364
364
|
def invalid?
|
365
|
-
@
|
365
|
+
@src == -1 || @dest == -1
|
366
366
|
end
|
367
367
|
|
368
368
|
#
|
@@ -381,7 +381,7 @@ module Zakuro
|
|
381
381
|
# @return [Integer] 間隔
|
382
382
|
#
|
383
383
|
def interval
|
384
|
-
@
|
384
|
+
@src - @dest
|
385
385
|
end
|
386
386
|
|
387
387
|
#
|
@@ -428,22 +428,22 @@ module Zakuro
|
|
428
428
|
# Leaped 閏有無
|
429
429
|
#
|
430
430
|
class Leaped
|
431
|
-
# @return [True, False]
|
432
|
-
attr_reader :
|
433
|
-
# @return [True, False]
|
434
|
-
attr_reader :
|
431
|
+
# @return [True, False] 移動元
|
432
|
+
attr_reader :src
|
433
|
+
# @return [True, False] 移動先
|
434
|
+
attr_reader :dest
|
435
435
|
|
436
436
|
# :reek:BooleanParameter
|
437
437
|
|
438
438
|
#
|
439
439
|
# 初期化
|
440
440
|
#
|
441
|
-
# @param [True, False]
|
442
|
-
# @param [True, False]
|
441
|
+
# @param [True, False] src 移動元
|
442
|
+
# @param [True, False] dest 移動先
|
443
443
|
#
|
444
|
-
def initialize(
|
445
|
-
@
|
446
|
-
@
|
444
|
+
def initialize(src: false, dest: false)
|
445
|
+
@src = src
|
446
|
+
@dest = dest
|
447
447
|
end
|
448
448
|
|
449
449
|
#
|
@@ -453,7 +453,7 @@ module Zakuro
|
|
453
453
|
# @return [False] 有効
|
454
454
|
#
|
455
455
|
def invalid?
|
456
|
-
!@
|
456
|
+
!@src && !@dest
|
457
457
|
end
|
458
458
|
end
|
459
459
|
|
@@ -469,12 +469,12 @@ module Zakuro
|
|
469
469
|
#
|
470
470
|
# 初期化
|
471
471
|
#
|
472
|
-
# @param [String]
|
473
|
-
# @param [String]
|
472
|
+
# @param [String] src 移動元
|
473
|
+
# @param [String] dest 移動先
|
474
474
|
#
|
475
|
-
def initialize(
|
476
|
-
@
|
477
|
-
@
|
475
|
+
def initialize(src: '小', dest: '小')
|
476
|
+
@src = src
|
477
|
+
@dest = dest
|
478
478
|
end
|
479
479
|
|
480
480
|
#
|
@@ -483,8 +483,8 @@ module Zakuro
|
|
483
483
|
# @return [True] 大
|
484
484
|
# @return [False] 小
|
485
485
|
#
|
486
|
-
def
|
487
|
-
@
|
486
|
+
def src
|
487
|
+
@src == BIG
|
488
488
|
end
|
489
489
|
|
490
490
|
#
|
@@ -493,8 +493,8 @@ module Zakuro
|
|
493
493
|
# @return [True] 大
|
494
494
|
# @return [False] 小
|
495
495
|
#
|
496
|
-
def
|
497
|
-
@
|
496
|
+
def dest
|
497
|
+
@dest == BIG
|
498
498
|
end
|
499
499
|
|
500
500
|
#
|
@@ -504,7 +504,7 @@ module Zakuro
|
|
504
504
|
# @return [False] 有効
|
505
505
|
#
|
506
506
|
def invalid?
|
507
|
-
@
|
507
|
+
@src == @dest
|
508
508
|
end
|
509
509
|
end
|
510
510
|
end
|