zakuro 0.6.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +3 -0
  3. data/README.md +58 -16
  4. data/VERSION +1 -1
  5. data/doc/dropped_date.md +93 -0
  6. data/doc/error.md +45 -0
  7. data/doc/operation/transfer.rb +8 -8
  8. data/lib/zakuro/calculation/base/day.rb +52 -0
  9. data/lib/zakuro/calculation/base/gengou.rb +50 -4
  10. data/lib/zakuro/calculation/base/linear_gengou.rb +6 -6
  11. data/lib/zakuro/calculation/base/operated_year.rb +3 -3
  12. data/lib/zakuro/calculation/base/year.rb +4 -4
  13. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +5 -3
  14. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +209 -0
  15. data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
  16. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +107 -0
  17. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +214 -0
  18. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +104 -0
  19. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +230 -0
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +193 -0
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
  22. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
  23. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +158 -0
  24. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
  25. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +75 -0
  26. data/lib/zakuro/calculation/{gengou → era/gengou}/internal/reserve.rb +6 -7
  27. data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
  28. data/lib/zakuro/calculation/{version → era/version}/internal/crawler.rb +7 -7
  29. data/lib/zakuro/calculation/{version → era/version}/internal/range.rb +4 -4
  30. data/lib/zakuro/calculation/{version → era/version}/version.rb +3 -3
  31. data/lib/zakuro/calculation/monthly/initialized_month.rb +1 -1
  32. data/lib/zakuro/calculation/monthly/month.rb +44 -5
  33. data/lib/zakuro/calculation/monthly/operated_month.rb +2 -2
  34. data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
  35. data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
  36. data/lib/zakuro/calculation/range/{full_range.rb → abstract_full_range.rb} +29 -27
  37. data/lib/zakuro/calculation/range/{operated_range.rb → abstract_operation_range.rb} +11 -14
  38. data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
  39. data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
  40. data/lib/zakuro/calculation/range/medieval_annual_range.rb +2 -2
  41. data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
  42. data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
  43. data/lib/zakuro/calculation/range/operated_solar_terms.rb +9 -11
  44. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +6 -6
  45. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +2 -0
  46. data/lib/zakuro/calculation/summary/internal/day.rb +40 -0
  47. data/lib/zakuro/calculation/summary/internal/month.rb +92 -0
  48. data/lib/zakuro/calculation/summary/{single.rb → internal/operation.rb} +6 -40
  49. data/lib/zakuro/calculation/summary/internal/option.rb +85 -0
  50. data/lib/zakuro/calculation/summary/japan/range.rb +158 -0
  51. data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
  52. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +96 -0
  53. data/lib/zakuro/calculation/summary/western/range.rb +124 -0
  54. data/lib/zakuro/calculation/summary/western/single.rb +113 -0
  55. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +174 -0
  56. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +98 -0
  57. data/lib/zakuro/calculation/type/optional.rb +46 -0
  58. data/lib/zakuro/condition.rb +75 -22
  59. data/lib/zakuro/context/context.rb +44 -0
  60. data/lib/zakuro/context/option.rb +117 -0
  61. data/lib/zakuro/context/version_class_resolver.rb +110 -0
  62. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +125 -0
  63. data/lib/zakuro/era/japan/gengou/alignment/division.rb +168 -0
  64. data/lib/zakuro/era/japan/gengou/alignment/line.rb +175 -0
  65. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +187 -0
  66. data/lib/zakuro/era/japan/gengou/alignment.rb +55 -0
  67. data/lib/zakuro/era/japan/gengou/resource/parser.rb +245 -0
  68. data/lib/zakuro/era/japan/gengou/resource/type.rb +299 -0
  69. data/lib/zakuro/era/japan/gengou/resource/validator.rb +347 -0
  70. data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-001-until-south.yaml +2 -2
  71. data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-002-from-north.yaml +2 -2
  72. data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-003-modern.yaml +2 -2
  73. data/lib/zakuro/era/japan/gengou/resource.rb +33 -0
  74. data/lib/zakuro/era/japan/gengou.rb +25 -79
  75. data/lib/zakuro/era/japan/version.rb +18 -18
  76. data/lib/zakuro/era/western/calendar.rb +13 -9
  77. data/lib/zakuro/exception/case/pattern.rb +71 -0
  78. data/lib/zakuro/exception/case/preset.rb +51 -0
  79. data/lib/zakuro/exception/case/template.rb +48 -0
  80. data/lib/zakuro/exception/cause.rb +28 -0
  81. data/lib/zakuro/exception/exception.rb +37 -0
  82. data/lib/zakuro/exception/zakuro_error.rb +46 -0
  83. data/lib/zakuro/gateway/locale/date.rb +127 -0
  84. data/lib/zakuro/gateway/locale/range.rb +67 -0
  85. data/lib/zakuro/gateway/range.rb +99 -0
  86. data/lib/zakuro/gateway/single.rb +70 -0
  87. data/lib/zakuro/merchant.rb +84 -12
  88. data/lib/zakuro/operation/month/parser.rb +11 -9
  89. data/lib/zakuro/operation/month/type.rb +31 -31
  90. data/lib/zakuro/operation/month/validator.rb +50 -50
  91. data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
  92. data/lib/zakuro/output/logger.rb +17 -3
  93. data/lib/zakuro/output/response.rb +24 -57
  94. data/lib/zakuro/result/data/day.rb +43 -0
  95. data/lib/zakuro/result/data/gengou.rb +35 -0
  96. data/lib/zakuro/result/data/month.rb +63 -0
  97. data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
  98. data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
  99. data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
  100. data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
  101. data/lib/zakuro/result/data/single_day.rb +56 -0
  102. data/lib/zakuro/result/data/solar_term.rb +35 -0
  103. data/lib/zakuro/result/data/year.rb +45 -0
  104. data/lib/zakuro/result/operation/bundle.rb +44 -0
  105. data/lib/zakuro/result/operation/month/annotation.rb +40 -0
  106. data/lib/zakuro/result/operation/month/bundle.rb +36 -0
  107. data/lib/zakuro/result/operation/month/history.rb +54 -0
  108. data/lib/zakuro/result/result.rb +21 -2
  109. data/lib/zakuro/tools/stringifier.rb +26 -3
  110. data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
  111. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
  112. data/lib/zakuro/version/daien/range/annual_range.rb +1 -1
  113. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +2 -0
  114. data/lib/zakuro/version/daien/stella/lunar/value.rb +2 -0
  115. data/lib/zakuro/version/genka/cycle/remainder.rb +2 -2
  116. data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
  117. data/lib/zakuro/version/genka/range/annual_range.rb +1 -1
  118. data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
  119. data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
  120. data/lib/zakuro/version/gihou/range/annual_range.rb +1 -1
  121. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +2 -0
  122. data/lib/zakuro/version/gihou/stella/lunar/value.rb +2 -0
  123. data/lib/zakuro/version/senmyou/README.md +11 -7
  124. data/lib/zakuro/version/senmyou/const/remainder.rb +5 -0
  125. data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
  126. data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
  127. data/lib/zakuro/version/senmyou/range/annual_range.rb +1 -1
  128. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +2 -0
  129. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +2 -0
  130. metadata +85 -24
  131. data/lib/zakuro/calculation/gengou/internal/counter.rb +0 -129
  132. data/lib/zakuro/calculation/gengou/internal/reserve/interval.rb +0 -183
  133. data/lib/zakuro/calculation/gengou/internal/reserve/list.rb +0 -382
  134. data/lib/zakuro/calculation/gengou/scroll.rb +0 -262
  135. data/lib/zakuro/calculation/specifier/single_day.rb +0 -87
  136. data/lib/zakuro/era/japan/gengou/parser.rb +0 -237
  137. data/lib/zakuro/era/japan/gengou/type.rb +0 -285
  138. data/lib/zakuro/era/japan/gengou/validator.rb +0 -341
  139. data/lib/zakuro/result/data.rb +0 -187
  140. data/lib/zakuro/result/operation.rb +0 -114
  141. data/lib/zakuro/version/context.rb +0 -44
  142. data/lib/zakuro/version/version_class_resolver.rb +0 -74
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zakuro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pldb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-15 00:00:00.000000000 Z
11
+ date: 2022-06-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: mainly lunar solar calendar
14
14
  email:
@@ -29,6 +29,8 @@ files:
29
29
  - VERSION
30
30
  - bin/console
31
31
  - bin/setup
32
+ - doc/dropped_date.md
33
+ - doc/error.md
32
34
  - doc/gengou.md
33
35
  - doc/operation.md
34
36
  - doc/operation/csv/month.csv
@@ -41,6 +43,7 @@ files:
41
43
  - images/各月の求め方.png
42
44
  - images/太陽と月.png
43
45
  - lib/zakuro.rb
46
+ - lib/zakuro/calculation/base/day.rb
44
47
  - lib/zakuro/calculation/base/gengou.rb
45
48
  - lib/zakuro/calculation/base/linear_gengou.rb
46
49
  - lib/zakuro/calculation/base/operated_year.rb
@@ -48,45 +51,89 @@ files:
48
51
  - lib/zakuro/calculation/cycle/abstract_remainder.rb
49
52
  - lib/zakuro/calculation/cycle/abstract_solar_term.rb
50
53
  - lib/zakuro/calculation/cycle/zodiac.rb
51
- - lib/zakuro/calculation/gengou/internal/counter.rb
52
- - lib/zakuro/calculation/gengou/internal/reserve.rb
53
- - lib/zakuro/calculation/gengou/internal/reserve/interval.rb
54
- - lib/zakuro/calculation/gengou/internal/reserve/list.rb
55
- - lib/zakuro/calculation/gengou/scroll.rb
54
+ - lib/zakuro/calculation/era/gengou/abstract_scroll.rb
55
+ - lib/zakuro/calculation/era/gengou/dated_scroll.rb
56
+ - lib/zakuro/calculation/era/gengou/internal/connector.rb
57
+ - lib/zakuro/calculation/era/gengou/internal/counter.rb
58
+ - lib/zakuro/calculation/era/gengou/internal/publisher.rb
59
+ - lib/zakuro/calculation/era/gengou/internal/reserve.rb
60
+ - lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb
61
+ - lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb
62
+ - lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb
63
+ - lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb
64
+ - lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb
65
+ - lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb
66
+ - lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb
67
+ - lib/zakuro/calculation/era/gengou/named_scroll.rb
68
+ - lib/zakuro/calculation/era/version/internal/crawler.rb
69
+ - lib/zakuro/calculation/era/version/internal/range.rb
70
+ - lib/zakuro/calculation/era/version/version.rb
56
71
  - lib/zakuro/calculation/monthly/abstract_lunar_phase.rb
57
72
  - lib/zakuro/calculation/monthly/first_day.rb
58
73
  - lib/zakuro/calculation/monthly/initialized_month.rb
59
74
  - lib/zakuro/calculation/monthly/month.rb
60
75
  - lib/zakuro/calculation/monthly/month_label.rb
61
76
  - lib/zakuro/calculation/monthly/operated_month.rb
62
- - lib/zakuro/calculation/range/full_range.rb
77
+ - lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb
78
+ - lib/zakuro/calculation/option/dropped_date/location.rb
79
+ - lib/zakuro/calculation/range/abstract_full_range.rb
80
+ - lib/zakuro/calculation/range/abstract_operation_range.rb
81
+ - lib/zakuro/calculation/range/dated_full_range.rb
82
+ - lib/zakuro/calculation/range/dated_operation_range.rb
63
83
  - lib/zakuro/calculation/range/medieval_annual_range.rb
64
- - lib/zakuro/calculation/range/operated_range.rb
84
+ - lib/zakuro/calculation/range/named_full_range.rb
85
+ - lib/zakuro/calculation/range/named_operation_range.rb
65
86
  - lib/zakuro/calculation/range/operated_solar_terms.rb
66
87
  - lib/zakuro/calculation/range/transfer/gengou_scroller.rb
67
88
  - lib/zakuro/calculation/range/transfer/year_boundary.rb
68
- - lib/zakuro/calculation/specifier/single_day.rb
69
89
  - lib/zakuro/calculation/stella/lunar/abstract_location.rb
70
90
  - lib/zakuro/calculation/stella/lunar/choukei_value.rb
71
91
  - lib/zakuro/calculation/stella/solar/abstract_average.rb
72
92
  - lib/zakuro/calculation/stella/solar/abstract_location.rb
73
93
  - lib/zakuro/calculation/stella/solar/choukei_value.rb
74
- - lib/zakuro/calculation/summary/single.rb
94
+ - lib/zakuro/calculation/summary/internal/day.rb
95
+ - lib/zakuro/calculation/summary/internal/month.rb
96
+ - lib/zakuro/calculation/summary/internal/operation.rb
97
+ - lib/zakuro/calculation/summary/internal/option.rb
98
+ - lib/zakuro/calculation/summary/japan/range.rb
99
+ - lib/zakuro/calculation/summary/japan/single.rb
100
+ - lib/zakuro/calculation/summary/japan/specifier/single_day.rb
101
+ - lib/zakuro/calculation/summary/western/range.rb
102
+ - lib/zakuro/calculation/summary/western/single.rb
103
+ - lib/zakuro/calculation/summary/western/specifier/multiple_day.rb
104
+ - lib/zakuro/calculation/summary/western/specifier/single_day.rb
75
105
  - lib/zakuro/calculation/type/old_float.rb
76
- - lib/zakuro/calculation/version/internal/crawler.rb
77
- - lib/zakuro/calculation/version/internal/range.rb
78
- - lib/zakuro/calculation/version/version.rb
106
+ - lib/zakuro/calculation/type/optional.rb
79
107
  - lib/zakuro/condition.rb
108
+ - lib/zakuro/context/context.rb
109
+ - lib/zakuro/context/option.rb
110
+ - lib/zakuro/context/version_class_resolver.rb
80
111
  - lib/zakuro/era/japan/calendar.rb
81
112
  - lib/zakuro/era/japan/gengou.rb
82
- - lib/zakuro/era/japan/gengou/parser.rb
83
- - lib/zakuro/era/japan/gengou/type.rb
84
- - lib/zakuro/era/japan/gengou/validator.rb
85
- - lib/zakuro/era/japan/gengou/yaml/set-001-until-south.yaml
86
- - lib/zakuro/era/japan/gengou/yaml/set-002-from-north.yaml
87
- - lib/zakuro/era/japan/gengou/yaml/set-003-modern.yaml
113
+ - lib/zakuro/era/japan/gengou/alignment.rb
114
+ - lib/zakuro/era/japan/gengou/alignment/aligner.rb
115
+ - lib/zakuro/era/japan/gengou/alignment/division.rb
116
+ - lib/zakuro/era/japan/gengou/alignment/line.rb
117
+ - lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb
118
+ - lib/zakuro/era/japan/gengou/resource.rb
119
+ - lib/zakuro/era/japan/gengou/resource/parser.rb
120
+ - lib/zakuro/era/japan/gengou/resource/type.rb
121
+ - lib/zakuro/era/japan/gengou/resource/validator.rb
122
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml
123
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml
124
+ - lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml
88
125
  - lib/zakuro/era/japan/version.rb
89
126
  - lib/zakuro/era/western/calendar.rb
127
+ - lib/zakuro/exception/case/pattern.rb
128
+ - lib/zakuro/exception/case/preset.rb
129
+ - lib/zakuro/exception/case/template.rb
130
+ - lib/zakuro/exception/cause.rb
131
+ - lib/zakuro/exception/exception.rb
132
+ - lib/zakuro/exception/zakuro_error.rb
133
+ - lib/zakuro/gateway/locale/date.rb
134
+ - lib/zakuro/gateway/locale/range.rb
135
+ - lib/zakuro/gateway/range.rb
136
+ - lib/zakuro/gateway/single.rb
90
137
  - lib/zakuro/merchant.rb
91
138
  - lib/zakuro/operation/month/parser.rb
92
139
  - lib/zakuro/operation/month/type.rb
@@ -97,19 +144,31 @@ files:
97
144
  - lib/zakuro/output/logger.rb
98
145
  - lib/zakuro/output/response.rb
99
146
  - lib/zakuro/result/core.rb
100
- - lib/zakuro/result/data.rb
101
- - lib/zakuro/result/operation.rb
147
+ - lib/zakuro/result/data/day.rb
148
+ - lib/zakuro/result/data/gengou.rb
149
+ - lib/zakuro/result/data/month.rb
150
+ - lib/zakuro/result/data/option/abstract_option.rb
151
+ - lib/zakuro/result/data/option/dropped_date/calculation.rb
152
+ - lib/zakuro/result/data/option/dropped_date/option.rb
153
+ - lib/zakuro/result/data/option/dropped_date/solar_term.rb
154
+ - lib/zakuro/result/data/single_day.rb
155
+ - lib/zakuro/result/data/solar_term.rb
156
+ - lib/zakuro/result/data/year.rb
157
+ - lib/zakuro/result/operation/bundle.rb
158
+ - lib/zakuro/result/operation/month/annotation.rb
159
+ - lib/zakuro/result/operation/month/bundle.rb
160
+ - lib/zakuro/result/operation/month/history.rb
102
161
  - lib/zakuro/result/result.rb
103
162
  - lib/zakuro/tools/stringifier.rb
104
163
  - lib/zakuro/tools/typeconv.rb
105
164
  - lib/zakuro/tools/typeof.rb
106
- - lib/zakuro/version/context.rb
107
165
  - lib/zakuro/version/daien/const/number.rb
108
166
  - lib/zakuro/version/daien/const/remainder.rb
109
167
  - lib/zakuro/version/daien/cycle/remainder.rb
110
168
  - lib/zakuro/version/daien/cycle/solar_term.rb
111
169
  - lib/zakuro/version/daien/daien.rb
112
170
  - lib/zakuro/version/daien/monthly/lunar_phase.rb
171
+ - lib/zakuro/version/daien/option/dropped_date/parameter.rb
113
172
  - lib/zakuro/version/daien/range/annual_range.rb
114
173
  - lib/zakuro/version/daien/stella/lunar/adjustment.rb
115
174
  - lib/zakuro/version/daien/stella/lunar/localization.rb
@@ -129,6 +188,7 @@ files:
129
188
  - lib/zakuro/version/genka/cycle/solar_term.rb
130
189
  - lib/zakuro/version/genka/genka.rb
131
190
  - lib/zakuro/version/genka/monthly/lunar_phase.rb
191
+ - lib/zakuro/version/genka/option/dropped_date/parameter.rb
132
192
  - lib/zakuro/version/genka/range/annual_range.rb
133
193
  - lib/zakuro/version/genka/stella/origin/first_term.rb
134
194
  - lib/zakuro/version/genka/stella/origin/january.rb
@@ -139,6 +199,7 @@ files:
139
199
  - lib/zakuro/version/gihou/cycle/solar_term.rb
140
200
  - lib/zakuro/version/gihou/gihou.rb
141
201
  - lib/zakuro/version/gihou/monthly/lunar_phase.rb
202
+ - lib/zakuro/version/gihou/option/dropped_date/parameter.rb
142
203
  - lib/zakuro/version/gihou/range/annual_range.rb
143
204
  - lib/zakuro/version/gihou/stella/lunar/adjustment.rb
144
205
  - lib/zakuro/version/gihou/stella/lunar/localization.rb
@@ -162,6 +223,7 @@ files:
162
223
  - lib/zakuro/version/senmyou/cycle/remainder.rb
163
224
  - lib/zakuro/version/senmyou/cycle/solar_term.rb
164
225
  - lib/zakuro/version/senmyou/monthly/lunar_phase.rb
226
+ - lib/zakuro/version/senmyou/option/dropped_date/parameter.rb
165
227
  - lib/zakuro/version/senmyou/range/annual_range.rb
166
228
  - lib/zakuro/version/senmyou/senmyou.rb
167
229
  - lib/zakuro/version/senmyou/stella/lunar/adjustment.rb
@@ -177,7 +239,6 @@ files:
177
239
  - lib/zakuro/version/senmyou/stella/solar/location.rb
178
240
  - lib/zakuro/version/senmyou/stella/solar/value.rb
179
241
  - lib/zakuro/version/tenpou/tenpou.rb
180
- - lib/zakuro/version/version_class_resolver.rb
181
242
  - zakuro.gemspec
182
243
  homepage: https://github.com/pldb/zakuro
183
244
  licenses:
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../../era/japan/gengou'
4
- require_relative '../../../era/japan/calendar'
5
- require_relative '../../../era/western/calendar'
6
-
7
- # :nodoc:
8
- module Zakuro
9
- # :nodoc:
10
- module Calculation
11
- # :nodoc:
12
- module Gengou
13
- #
14
- # Counter 加算元号
15
- #
16
- class Counter
17
- # @return [Integer] 不正値
18
- INVALID_YEAR = -1
19
-
20
- # @return [Japan::Gengou] 元号
21
- attr_reader :gengou
22
- # @return [Integer] 元号年
23
- attr_reader :japan_year
24
- # @return [Integer] 西暦年
25
- attr_reader :western_year
26
-
27
- #
28
- # 初期化
29
- #
30
- # @param [Japan::Gengou] gengou 元号
31
- #
32
- def initialize(gengou: Japan::Gengou.new)
33
- @gengou = gengou
34
- @japan_year = gengou.both_start_year.japan
35
- @western_year = gengou.both_start_year.western
36
- end
37
-
38
- #
39
- # 和暦開始日を取得する
40
- #
41
- # @return [Japan::Calendar] 和暦開始日
42
- #
43
- def japan_start_date
44
- return Japan::Calendar.new if @gengou.invalid?
45
-
46
- @gengou.both_start_date.japan
47
- end
48
-
49
- #
50
- # 西暦開始日を取得する
51
- #
52
- # @return [Western::Calendar] 西暦開始日
53
- #
54
- def western_start_date
55
- return Western::Calendar.new if @gengou.invalid?
56
-
57
- @gengou.both_start_date.western
58
- end
59
-
60
- #
61
- # 西暦終了日を取得する
62
- #
63
- # @return [Western::Calendar] 西暦終了日
64
- #
65
- def western_end_date
66
- return Western::Calendar.new if @gengou.invalid?
67
-
68
- @gengou.end_date
69
- end
70
-
71
- #
72
- # 次年にする
73
- #
74
- # @return [MultiGengou] 自身
75
- #
76
- def next_year
77
- @japan_year += 1
78
- @western_year += 1
79
-
80
- self
81
- end
82
-
83
- #
84
- # 元号名を取得する
85
- #
86
- # @return [String] 元号名
87
- #
88
- def name
89
- return '' unless @gengou
90
-
91
- @gengou.name
92
- end
93
-
94
- #
95
- # 不正か
96
- #
97
- # @return [True] 不正
98
- # @return [False] 不正なし
99
- #
100
- def invalid?
101
- @gengou.invalid? || @japan_year == INVALID_YEAR || @western_year == INVALID_YEAR
102
- end
103
-
104
- #
105
- # 指定した日が元号に含まれるか
106
- #
107
- # @param [Western::Calendar] date 日
108
- #
109
- # @return [True] 含まれる
110
- # @return [False] 含まれない
111
- #
112
- def include?
113
- @gengou.include?
114
- end
115
-
116
- #
117
- # ディープコピー
118
- #
119
- # @param [MultiGengou] obj 自身
120
- #
121
- def initialize_copy(obj)
122
- @gengou = obj.gengou.clone
123
- @japan_year = obj.japan_year
124
- @western_year = obj.western_year
125
- end
126
- end
127
- end
128
- end
129
- end
@@ -1,183 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../../../../era/western/calendar'
4
-
5
- require_relative './list'
6
-
7
- # :nodoc:
8
- module Zakuro
9
- # :nodoc:
10
- module Calculation
11
- # :nodoc:
12
- module Gengou
13
- # :nodoc:
14
- module Reserve
15
- # Interval
16
- #
17
- # 予約済み計算範囲
18
- #
19
- class Interval
20
- # @return [List] 1行目元号
21
- attr_reader :first_gengou
22
- # @return [List] 2行目元号
23
- attr_reader :second_gengou
24
-
25
- #
26
- # 初期化
27
- #
28
- # @param [Western::Calendar] start_date 西暦開始日
29
- # @param [Western::Calendar] end_date 西暦終了日
30
- #
31
- def initialize(start_date: Western::Calendar.new, end_date: Western::Calendar.new)
32
- @first_gengou = List.new(first: true, start_date: start_date, end_date: end_date)
33
- @second_gengou = List.new(first: false, start_date: start_date, end_date: end_date)
34
- end
35
-
36
- #
37
- # 不正か
38
- #
39
- # @return [True] 不正
40
- # @return [False] 不正なし
41
- #
42
- def invalid?
43
- @first_gengou.invalid?
44
- end
45
-
46
- #
47
- # 1行目元号を取得する
48
- #
49
- # @param [Western::Calendar] western_date 西暦日
50
- #
51
- # @return [Gengou::Counter] 加算元号
52
- #
53
- def match_first_gengou(western_date: Western::Calendar.new)
54
- @first_gengou.get(western_date: western_date)
55
- end
56
-
57
- #
58
- # 2行目元号を取得する
59
- #
60
- # @param [Western::Calendar] western_date 西暦日
61
- #
62
- # @return [Gengou::Counter] 加算元号
63
- #
64
- def match_second_gengou(western_date: Western::Calendar.new)
65
- @second_gengou.get(western_date: western_date)
66
- end
67
-
68
- #
69
- # 範囲内元号(1行目元号)を取得する
70
- #
71
- # @param [Western::Calendar] start_date 西暦開始日
72
- # @param [Western::Calendar] end_date 西暦終了日
73
- #
74
- # @return [Array<Gengou::Counter>] 範囲内元号(1行目元号)
75
- #
76
- def collect_first_gengou(start_date: Western::Calendar.new,
77
- end_date: Western::Calendar.new)
78
- @first_gengou.collect(start_date: start_date, end_date: end_date)
79
- end
80
-
81
- #
82
- # 範囲内元号(2行目元号)を取得する
83
- #
84
- # @param [Western::Calendar] start_date 西暦開始日
85
- # @param [Western::Calendar] end_date 西暦終了日
86
- #
87
- # @return [Array<Gengou::Counter>] 範囲内元号(2行目元号)
88
- #
89
- def collect_second_gengou(start_date: Western::Calendar.new,
90
- end_date: Western::Calendar.new)
91
- @second_gengou.collect(start_date: start_date, end_date: end_date)
92
- end
93
-
94
- #
95
- # 最古の元号から和暦開始日を取得する
96
- #
97
- # @return [Japan::Calendar] 和暦開始日
98
- #
99
- def japan_start_date
100
- gengou = oldest_gengou
101
-
102
- return Japan::Calendar.new if gengou.invalid?
103
-
104
- gengou.japan_start_date
105
- end
106
-
107
- #
108
- # 最古の元号から西暦開始日を取得する
109
- #
110
- # @return [Western::Calendar] 西暦開始日
111
- #
112
- def western_start_date
113
- gengou = oldest_gengou
114
-
115
- return Western::Calendar.new if gengou.invalid?
116
-
117
- gengou.western_start_date
118
- end
119
-
120
- #
121
- # 開始西暦年を取得する
122
- #
123
- # @return [Integer] 開始西暦年
124
- #
125
- def western_start_year
126
- first_start_year = @first_gengou.western_start_year
127
- second_start_year = @second_gengou.western_start_year
128
-
129
- return first_start_year if @first_gengou.invalid?
130
-
131
- return first_start_year if @second_gengou.invalid?
132
-
133
- return first_start_year if first_start_year < second_start_year
134
-
135
- second_start_year
136
- end
137
-
138
- #
139
- # 終了西暦年を取得する
140
- #
141
- # @return [Integer] 終了西暦年
142
- #
143
- def western_end_year
144
- first_end_year = @first_gengou.western_end_year
145
- second_end_year = @second_gengou.western_end_year
146
-
147
- return first_end_year if @first_gengou.invalid?
148
-
149
- return first_end_year if @second_gengou.invalid?
150
-
151
- return first_end_year if first_end_year > second_end_year
152
-
153
- second_end_year
154
- end
155
-
156
- private
157
-
158
- #
159
- # 最古の元号を取得する
160
- #
161
- # @return [Japan::Gengou] 最古の元号
162
- #
163
- def oldest_gengou
164
- return @first_gengou if @first_gengou.invalid?
165
-
166
- return @first_gengou if @second_gengou.invalid?
167
-
168
- first_western_date = @first_gengou.western_start_date
169
- second_western_date = @second_gengou.western_start_date
170
-
171
- return @first_gengou if first_western_date.invalid?
172
-
173
- return @first_gengou if second_western_date.invalid?
174
-
175
- return @first_gengou if first_western_date < second_western_date
176
-
177
- @second_gengou
178
- end
179
- end
180
- end
181
- end
182
- end
183
- end