zakuro 0.6.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +3 -0
  3. data/README.md +46 -17
  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 +49 -3
  10. data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
  11. data/lib/zakuro/calculation/base/operated_year.rb +26 -24
  12. data/lib/zakuro/calculation/base/year.rb +7 -7
  13. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
  14. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
  15. data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
  16. data/lib/zakuro/calculation/era/gengou/{scroll.rb → abstract_scroll.rb} +44 -37
  17. data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
  18. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
  19. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
  20. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/{list.rb → abstract_list.rb} +50 -64
  22. data/lib/zakuro/calculation/era/gengou/internal/reserve/{range.rb → abstract_range.rb} +73 -50
  23. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
  24. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
  25. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +156 -0
  26. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
  27. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +73 -0
  28. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +23 -22
  29. data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
  30. data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
  31. data/lib/zakuro/calculation/era/version/version.rb +12 -10
  32. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
  33. data/lib/zakuro/calculation/monthly/const.rb +18 -0
  34. data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
  35. data/lib/zakuro/calculation/monthly/month.rb +55 -16
  36. data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
  37. data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
  38. data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
  39. data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
  40. data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
  41. data/lib/zakuro/calculation/range/{full_range.rb → abstract_full_range.rb} +45 -29
  42. data/lib/zakuro/calculation/range/abstract_operation_range.rb +193 -0
  43. data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
  44. data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
  45. data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
  46. data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
  47. data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
  48. data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
  49. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
  50. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
  51. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
  52. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
  53. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
  54. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
  55. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
  56. data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
  57. data/lib/zakuro/calculation/{specifier → summary}/internal/month.rb +33 -12
  58. data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
  59. data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
  60. data/lib/zakuro/calculation/summary/japan/range.rb +179 -0
  61. data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
  62. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +98 -0
  63. data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
  64. data/lib/zakuro/calculation/summary/western/range.rb +127 -0
  65. data/lib/zakuro/calculation/summary/western/single.rb +115 -0
  66. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +173 -0
  67. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +100 -0
  68. data/lib/zakuro/calculation/type/old_float.rb +2 -2
  69. data/lib/zakuro/calculation/type/optional.rb +46 -0
  70. data/lib/zakuro/condition.rb +143 -94
  71. data/lib/zakuro/context/context.rb +44 -0
  72. data/lib/zakuro/context/option.rb +119 -0
  73. data/lib/zakuro/context/version_class_resolver.rb +112 -0
  74. data/lib/zakuro/era/japan/calendar.rb +35 -33
  75. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +93 -74
  76. data/lib/zakuro/era/japan/gengou/alignment/division.rb +135 -133
  77. data/lib/zakuro/era/japan/gengou/alignment/line.rb +143 -122
  78. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +177 -168
  79. data/lib/zakuro/era/japan/gengou/alignment.rb +40 -25
  80. data/lib/zakuro/era/japan/gengou/resource/parser.rb +199 -181
  81. data/lib/zakuro/era/japan/gengou/resource/type.rb +243 -234
  82. data/lib/zakuro/era/japan/gengou/resource/validator.rb +257 -254
  83. data/lib/zakuro/era/japan/gengou/resource.rb +23 -22
  84. data/lib/zakuro/era/japan/gengou.rb +28 -41
  85. data/lib/zakuro/era/japan/version.rb +18 -16
  86. data/lib/zakuro/era/western/calendar.rb +104 -88
  87. data/lib/zakuro/exception/case/pattern.rb +71 -0
  88. data/lib/zakuro/exception/case/preset.rb +51 -0
  89. data/lib/zakuro/exception/case/template.rb +48 -0
  90. data/lib/zakuro/exception/cause.rb +28 -0
  91. data/lib/zakuro/exception/exception.rb +39 -0
  92. data/lib/zakuro/exception/zakuro_error.rb +46 -0
  93. data/lib/zakuro/gateway/locale/date.rb +127 -0
  94. data/lib/zakuro/gateway/locale/range.rb +67 -0
  95. data/lib/zakuro/gateway/range.rb +99 -0
  96. data/lib/zakuro/gateway/single.rb +81 -0
  97. data/lib/zakuro/merchant.rb +67 -33
  98. data/lib/zakuro/operation/month/parser.rb +252 -249
  99. data/lib/zakuro/operation/month/type.rb +44 -35
  100. data/lib/zakuro/operation/month/validator.rb +182 -178
  101. data/lib/zakuro/operation/operation.rb +38 -36
  102. data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
  103. data/lib/zakuro/output/logger.rb +17 -3
  104. data/lib/zakuro/output/response.rb +107 -141
  105. data/lib/zakuro/result/data/day.rb +43 -0
  106. data/lib/zakuro/result/data/gengou.rb +35 -0
  107. data/lib/zakuro/result/data/month.rb +63 -0
  108. data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
  109. data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
  110. data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
  111. data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
  112. data/lib/zakuro/result/data/single_day.rb +56 -0
  113. data/lib/zakuro/result/data/solar_term.rb +35 -0
  114. data/lib/zakuro/result/data/year.rb +45 -0
  115. data/lib/zakuro/result/operation/month/annotation.rb +40 -0
  116. data/lib/zakuro/result/operation/month/history.rb +54 -0
  117. data/lib/zakuro/result/operation/month.rb +31 -0
  118. data/lib/zakuro/result/operation.rb +22 -97
  119. data/lib/zakuro/result/result.rb +6 -4
  120. data/lib/zakuro/tools/stringifier.rb +67 -42
  121. data/lib/zakuro/tools/typeconv.rb +17 -15
  122. data/lib/zakuro/tools/typeof.rb +15 -13
  123. data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
  124. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
  125. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
  126. data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
  127. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
  128. data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
  129. data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
  130. data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
  131. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
  132. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
  133. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
  134. data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
  135. data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
  136. data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
  137. data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
  138. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
  139. data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
  140. data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
  141. data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
  142. data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
  143. data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
  144. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
  145. data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
  146. data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
  147. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
  148. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
  149. data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
  150. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
  151. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
  152. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
  153. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
  154. data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
  155. data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
  156. data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
  157. data/lib/zakuro/version/senmyou/const/remainder.rb +5 -0
  158. data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
  159. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
  160. data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
  161. data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
  162. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
  163. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
  164. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
  165. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
  166. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
  167. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
  168. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
  169. data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
  170. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
  171. data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
  172. metadata +68 -16
  173. data/lib/zakuro/calculation/range/operated_range.rb +0 -193
  174. data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -220
  175. data/lib/zakuro/calculation/specifier/multiple_day.rb +0 -162
  176. data/lib/zakuro/calculation/specifier/single_day.rb +0 -87
  177. data/lib/zakuro/calculation/summary/range.rb +0 -120
  178. data/lib/zakuro/calculation/summary/single.rb +0 -110
  179. data/lib/zakuro/result/data.rb +0 -187
  180. data/lib/zakuro/version/context.rb +0 -44
  181. data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -26,7 +26,7 @@ module Zakuro
26
26
  # @param [Integer] western_year 西暦年
27
27
  #
28
28
  def initialize(western_year:)
29
- solar_term = Average.first_solar_term(western_year: western_year)
29
+ solar_term = self.class.first_solar_term(western_year: western_year)
30
30
  super(solar_term: solar_term)
31
31
  end
32
32
 
@@ -41,55 +41,57 @@ module Zakuro
41
41
  super(annual_range: annual_range)
42
42
  end
43
43
 
44
- #
45
- # 計算開始する二十四節気を求める
46
- #
47
- # @param [Integer] western_year 西暦年
48
- #
49
- # @return [SolarTerm] 二十四節気
50
- #
51
- def self.first_solar_term(western_year:)
52
- # 天正冬至
53
- winter_solstice = Origin::WinterSolstice.get(western_year: western_year)
54
-
55
- # 二十四節気(冬至)
56
- solar_term = Cycle::SolarTerm.new(index: 0, remainder: winter_solstice)
57
-
58
- first_solar_term_index = Average.calc_first_solar_term_index(western_year: western_year)
59
-
60
- # 対象の二十四節気まで戻す
61
- solar_term.prev_by_index(first_solar_term_index)
62
-
63
- solar_term
64
- end
65
-
66
- # :reek:TooManyStatements { max_statements: 6 }
67
-
68
- #
69
- # 計算開始する二十四節気番号を求める
70
- #
71
- # * 前提として入定気は冬至の手前にある
72
- # * 例えば、定気が大雪であれば入定気は大雪の範囲内にある
73
- # * 入定気は、定気の開始位置に重複しない限り、常に定気より後にある
74
- # * 基本的に定気の一つ前から起算すれば、当時から求めた11月(閏10/閏11月)に二十四節気を割り当てられる
75
- #
76
- # @param [Integer] western_year 西暦年
77
- #
78
- # @return [Integer] 二十四節気番号
79
- #
80
- def self.calc_first_solar_term_index(western_year:)
81
- # 天正閏余
82
- lunar_age = Origin::LunarAge.get(western_year: western_year)
83
-
84
- solar_location = Solar::Location.new(lunar_age: lunar_age)
85
- solar_location.run
86
-
87
- solar_term_index = solar_location.index
88
-
89
- # 入定気の一つ後の二十四節気まで戻す(ただし11月経朔が二十四節気上にある場合は戻さない)
90
- solar_term_index += 1 unless solar_location.remainder.day.zero?
91
-
92
- solar_term_index
44
+ class << self
45
+ #
46
+ # 計算開始する二十四節気を求める
47
+ #
48
+ # @param [Integer] western_year 西暦年
49
+ #
50
+ # @return [SolarTerm] 二十四節気
51
+ #
52
+ def first_solar_term(western_year:)
53
+ # 天正冬至
54
+ winter_solstice = Origin::WinterSolstice.get(western_year: western_year)
55
+
56
+ # 二十四節気(冬至)
57
+ solar_term = Cycle::SolarTerm.new(index: 0, remainder: winter_solstice)
58
+
59
+ first_solar_term_index = calc_first_solar_term_index(western_year: western_year)
60
+
61
+ # 対象の二十四節気まで戻す
62
+ solar_term.prev_by_index(first_solar_term_index)
63
+
64
+ solar_term
65
+ end
66
+
67
+ # :reek:TooManyStatements { max_statements: 6 }
68
+
69
+ #
70
+ # 計算開始する二十四節気番号を求める
71
+ #
72
+ # * 前提として入定気は冬至の手前にある
73
+ # * 例えば、定気が大雪であれば入定気は大雪の範囲内にある
74
+ # * 入定気は、定気の開始位置に重複しない限り、常に定気より後にある
75
+ # * 基本的に定気の一つ前から起算すれば、当時から求めた11月(閏10/閏11月)に二十四節気を割り当てられる
76
+ #
77
+ # @param [Integer] western_year 西暦年
78
+ #
79
+ # @return [Integer] 二十四節気番号
80
+ #
81
+ def calc_first_solar_term_index(western_year:)
82
+ # 天正閏余
83
+ lunar_age = Origin::LunarAge.get(western_year: western_year)
84
+
85
+ solar_location = Solar::Location.new(lunar_age: lunar_age)
86
+ solar_location.run
87
+
88
+ solar_term_index = solar_location.index
89
+
90
+ # 入定気の一つ後の二十四節気まで戻す(ただし11月経朔が二十四節気上にある場合は戻さない)
91
+ solar_term_index += 1 unless solar_location.remainder.day.zero?
92
+
93
+ solar_term_index
94
+ end
93
95
  end
94
96
  end
95
97
  end
@@ -78,24 +78,26 @@ module Zakuro
78
78
  MAP[:taisetsu] # 23
79
79
  ].freeze
80
80
 
81
- #
82
- # 入気定日加減数を引き当てる
83
- #
84
- # @param [Integer] index 二十四節気番号
85
- #
86
- # @return [Cycle::Remainder] 入気定日加減数
87
- #
88
- def self.index_of(index)
89
- LIST[index]
90
- end
81
+ class << self
82
+ #
83
+ # 入気定日加減数を引き当てる
84
+ #
85
+ # @param [Integer] index 二十四節気番号
86
+ #
87
+ # @return [Cycle::Remainder] 入気定日加減数
88
+ #
89
+ def index_of(index)
90
+ LIST[index]
91
+ end
91
92
 
92
- #
93
- # 入気定日加減数の総数を返す
94
- #
95
- # @return [Integer] 入気定日加減数の総数
96
- #
97
- def self.size
98
- LIST.size
93
+ #
94
+ # 入気定日加減数の総数を返す
95
+ #
96
+ # @return [Integer] 入気定日加減数の総数
97
+ #
98
+ def size
99
+ LIST.size
100
+ end
99
101
  end
100
102
  end
101
103
  end
@@ -19,19 +19,21 @@ module Zakuro
19
19
  # @return [Integer] 1日
20
20
  DAY = Const::Number::Cycle::DAY
21
21
 
22
- #
23
- # 太陽の運行による補正値を算出する
24
- #
25
- # @param [SolarTerm] solar_location 入定気
26
- #
27
- # @return [Integer] 補正値
28
- #
29
- def self.get(solar_location:)
30
- remainder = solar_location.remainder
22
+ class << self
23
+ #
24
+ # 太陽の運行による補正値を算出する
25
+ #
26
+ # @param [SolarTerm] solar_location 入定気
27
+ #
28
+ # @return [Integer] 補正値
29
+ #
30
+ def get(solar_location:)
31
+ remainder = solar_location.remainder
31
32
 
32
- row = Adjustment.specify(index: solar_location.index)
33
+ row = Adjustment.specify(index: solar_location.index)
33
34
 
34
- Calculation::Solar::ChoukeiValue.get(remainder: remainder, row: row)
35
+ Calculation::Solar::ChoukeiValue.get(remainder: remainder, row: row)
36
+ end
35
37
  end
36
38
  end
37
39
  end
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.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pldb
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-02 00:00:00.000000000 Z
11
+ date: 2022-07-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,41 +51,66 @@ 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
54
+ - lib/zakuro/calculation/era/gengou/abstract_scroll.rb
55
+ - lib/zakuro/calculation/era/gengou/dated_scroll.rb
51
56
  - lib/zakuro/calculation/era/gengou/internal/connector.rb
52
57
  - lib/zakuro/calculation/era/gengou/internal/counter.rb
53
58
  - lib/zakuro/calculation/era/gengou/internal/publisher.rb
54
59
  - lib/zakuro/calculation/era/gengou/internal/reserve.rb
55
- - lib/zakuro/calculation/era/gengou/internal/reserve/list.rb
56
- - lib/zakuro/calculation/era/gengou/internal/reserve/range.rb
57
- - lib/zakuro/calculation/era/gengou/scroll.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
58
68
  - lib/zakuro/calculation/era/version/internal/crawler.rb
59
69
  - lib/zakuro/calculation/era/version/internal/range.rb
60
70
  - lib/zakuro/calculation/era/version/version.rb
61
71
  - lib/zakuro/calculation/monthly/abstract_lunar_phase.rb
72
+ - lib/zakuro/calculation/monthly/const.rb
62
73
  - lib/zakuro/calculation/monthly/first_day.rb
63
74
  - lib/zakuro/calculation/monthly/initialized_month.rb
64
75
  - lib/zakuro/calculation/monthly/month.rb
65
76
  - lib/zakuro/calculation/monthly/month_label.rb
66
77
  - lib/zakuro/calculation/monthly/operated_month.rb
67
- - lib/zakuro/calculation/range/full_range.rb
78
+ - lib/zakuro/calculation/monthly/operated_solar_term.rb
79
+ - lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb
80
+ - lib/zakuro/calculation/option/dropped_date/location.rb
81
+ - lib/zakuro/calculation/range/abstract_full_range.rb
82
+ - lib/zakuro/calculation/range/abstract_operation_range.rb
83
+ - lib/zakuro/calculation/range/dated_full_range.rb
84
+ - lib/zakuro/calculation/range/dated_operation_range.rb
68
85
  - lib/zakuro/calculation/range/medieval_annual_range.rb
69
- - lib/zakuro/calculation/range/operated_range.rb
70
- - lib/zakuro/calculation/range/operated_solar_terms.rb
86
+ - lib/zakuro/calculation/range/named_full_range.rb
87
+ - lib/zakuro/calculation/range/named_operation_range.rb
88
+ - lib/zakuro/calculation/range/operated_solar_term.rb
71
89
  - lib/zakuro/calculation/range/transfer/gengou_scroller.rb
72
90
  - lib/zakuro/calculation/range/transfer/year_boundary.rb
73
- - lib/zakuro/calculation/specifier/internal/month.rb
74
- - lib/zakuro/calculation/specifier/multiple_day.rb
75
- - lib/zakuro/calculation/specifier/single_day.rb
76
91
  - lib/zakuro/calculation/stella/lunar/abstract_location.rb
77
92
  - lib/zakuro/calculation/stella/lunar/choukei_value.rb
78
93
  - lib/zakuro/calculation/stella/solar/abstract_average.rb
79
94
  - lib/zakuro/calculation/stella/solar/abstract_location.rb
80
95
  - lib/zakuro/calculation/stella/solar/choukei_value.rb
96
+ - lib/zakuro/calculation/summary/internal/day.rb
97
+ - lib/zakuro/calculation/summary/internal/month.rb
81
98
  - lib/zakuro/calculation/summary/internal/operation.rb
82
- - lib/zakuro/calculation/summary/range.rb
83
- - lib/zakuro/calculation/summary/single.rb
99
+ - lib/zakuro/calculation/summary/internal/option.rb
100
+ - lib/zakuro/calculation/summary/japan/range.rb
101
+ - lib/zakuro/calculation/summary/japan/single.rb
102
+ - lib/zakuro/calculation/summary/japan/specifier/single_day.rb
103
+ - lib/zakuro/calculation/summary/japan/specifier/specified_range.rb
104
+ - lib/zakuro/calculation/summary/western/range.rb
105
+ - lib/zakuro/calculation/summary/western/single.rb
106
+ - lib/zakuro/calculation/summary/western/specifier/multiple_day.rb
107
+ - lib/zakuro/calculation/summary/western/specifier/single_day.rb
84
108
  - lib/zakuro/calculation/type/old_float.rb
109
+ - lib/zakuro/calculation/type/optional.rb
85
110
  - lib/zakuro/condition.rb
111
+ - lib/zakuro/context/context.rb
112
+ - lib/zakuro/context/option.rb
113
+ - lib/zakuro/context/version_class_resolver.rb
86
114
  - lib/zakuro/era/japan/calendar.rb
87
115
  - lib/zakuro/era/japan/gengou.rb
88
116
  - lib/zakuro/era/japan/gengou/alignment.rb
@@ -99,6 +127,16 @@ files:
99
127
  - lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml
100
128
  - lib/zakuro/era/japan/version.rb
101
129
  - lib/zakuro/era/western/calendar.rb
130
+ - lib/zakuro/exception/case/pattern.rb
131
+ - lib/zakuro/exception/case/preset.rb
132
+ - lib/zakuro/exception/case/template.rb
133
+ - lib/zakuro/exception/cause.rb
134
+ - lib/zakuro/exception/exception.rb
135
+ - lib/zakuro/exception/zakuro_error.rb
136
+ - lib/zakuro/gateway/locale/date.rb
137
+ - lib/zakuro/gateway/locale/range.rb
138
+ - lib/zakuro/gateway/range.rb
139
+ - lib/zakuro/gateway/single.rb
102
140
  - lib/zakuro/merchant.rb
103
141
  - lib/zakuro/operation/month/parser.rb
104
142
  - lib/zakuro/operation/month/type.rb
@@ -109,19 +147,31 @@ files:
109
147
  - lib/zakuro/output/logger.rb
110
148
  - lib/zakuro/output/response.rb
111
149
  - lib/zakuro/result/core.rb
112
- - lib/zakuro/result/data.rb
150
+ - lib/zakuro/result/data/day.rb
151
+ - lib/zakuro/result/data/gengou.rb
152
+ - lib/zakuro/result/data/month.rb
153
+ - lib/zakuro/result/data/option/abstract_option.rb
154
+ - lib/zakuro/result/data/option/dropped_date/calculation.rb
155
+ - lib/zakuro/result/data/option/dropped_date/option.rb
156
+ - lib/zakuro/result/data/option/dropped_date/solar_term.rb
157
+ - lib/zakuro/result/data/single_day.rb
158
+ - lib/zakuro/result/data/solar_term.rb
159
+ - lib/zakuro/result/data/year.rb
113
160
  - lib/zakuro/result/operation.rb
161
+ - lib/zakuro/result/operation/month.rb
162
+ - lib/zakuro/result/operation/month/annotation.rb
163
+ - lib/zakuro/result/operation/month/history.rb
114
164
  - lib/zakuro/result/result.rb
115
165
  - lib/zakuro/tools/stringifier.rb
116
166
  - lib/zakuro/tools/typeconv.rb
117
167
  - lib/zakuro/tools/typeof.rb
118
- - lib/zakuro/version/context.rb
119
168
  - lib/zakuro/version/daien/const/number.rb
120
169
  - lib/zakuro/version/daien/const/remainder.rb
121
170
  - lib/zakuro/version/daien/cycle/remainder.rb
122
171
  - lib/zakuro/version/daien/cycle/solar_term.rb
123
172
  - lib/zakuro/version/daien/daien.rb
124
173
  - lib/zakuro/version/daien/monthly/lunar_phase.rb
174
+ - lib/zakuro/version/daien/option/dropped_date/parameter.rb
125
175
  - lib/zakuro/version/daien/range/annual_range.rb
126
176
  - lib/zakuro/version/daien/stella/lunar/adjustment.rb
127
177
  - lib/zakuro/version/daien/stella/lunar/localization.rb
@@ -141,6 +191,7 @@ files:
141
191
  - lib/zakuro/version/genka/cycle/solar_term.rb
142
192
  - lib/zakuro/version/genka/genka.rb
143
193
  - lib/zakuro/version/genka/monthly/lunar_phase.rb
194
+ - lib/zakuro/version/genka/option/dropped_date/parameter.rb
144
195
  - lib/zakuro/version/genka/range/annual_range.rb
145
196
  - lib/zakuro/version/genka/stella/origin/first_term.rb
146
197
  - lib/zakuro/version/genka/stella/origin/january.rb
@@ -151,6 +202,7 @@ files:
151
202
  - lib/zakuro/version/gihou/cycle/solar_term.rb
152
203
  - lib/zakuro/version/gihou/gihou.rb
153
204
  - lib/zakuro/version/gihou/monthly/lunar_phase.rb
205
+ - lib/zakuro/version/gihou/option/dropped_date/parameter.rb
154
206
  - lib/zakuro/version/gihou/range/annual_range.rb
155
207
  - lib/zakuro/version/gihou/stella/lunar/adjustment.rb
156
208
  - lib/zakuro/version/gihou/stella/lunar/localization.rb
@@ -174,6 +226,7 @@ files:
174
226
  - lib/zakuro/version/senmyou/cycle/remainder.rb
175
227
  - lib/zakuro/version/senmyou/cycle/solar_term.rb
176
228
  - lib/zakuro/version/senmyou/monthly/lunar_phase.rb
229
+ - lib/zakuro/version/senmyou/option/dropped_date/parameter.rb
177
230
  - lib/zakuro/version/senmyou/range/annual_range.rb
178
231
  - lib/zakuro/version/senmyou/senmyou.rb
179
232
  - lib/zakuro/version/senmyou/stella/lunar/adjustment.rb
@@ -189,7 +242,6 @@ files:
189
242
  - lib/zakuro/version/senmyou/stella/solar/location.rb
190
243
  - lib/zakuro/version/senmyou/stella/solar/value.rb
191
244
  - lib/zakuro/version/tenpou/tenpou.rb
192
- - lib/zakuro/version/version_class_resolver.rb
193
245
  - zakuro.gemspec
194
246
  homepage: https://github.com/pldb/zakuro
195
247
  licenses:
@@ -1,193 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative './operated_solar_terms'
4
- require_relative '../../operation/operation'
5
- require_relative '../base/operated_year'
6
- require_relative '../../calculation/monthly/operated_month'
7
- require_relative './transfer/gengou_scroller'
8
-
9
- # :nodoc:
10
- module Zakuro
11
- # :nodoc:
12
- module Calculation
13
- # :nodoc:
14
- module Range
15
- #
16
- # OperatedRange 運用結果範囲
17
- #
18
- # 何らかの理由により、計算された暦とは異なる運用結果である場合、その結果に合わせて計算結果を上書きする
19
- class OperatedRange
20
- # @return [Array<Year>] 年データ(完全範囲)
21
- attr_reader :years
22
- # @return [OperatedSolarTerms] 運用時二十四節気
23
- attr_reader :operated_solar_terms
24
- # @return [Context] 暦コンテキスト
25
- attr_reader :context
26
-
27
- #
28
- # 初期化
29
- #
30
- # @param [Context] context 暦コンテキスト
31
- # @param [Western::Calendar] start_date 開始日
32
- # @param [Western::Calendar] last_date 終了日
33
- # @param [Array<Year>] years 年データ(完全範囲)
34
- #
35
- def initialize(context:, start_date: Western::Calendar.new, last_date: Western::Calendar.new,
36
- years: [])
37
- @context = context
38
- @years = years
39
- @scroll = Gengou::Scroll.new(start_date: start_date, last_date: last_date)
40
- @operated_solar_terms = OperatedSolarTerms.new(context: context, years: @years)
41
- @operated_solar_terms.create
42
- end
43
-
44
- #
45
- # 運用結果範囲を取得する
46
- #
47
- # @return [Array<Year>] 運用結果範囲
48
- #
49
- def get
50
- operated_years = rewrite
51
-
52
- OperatedRange.move(operated_years: operated_years)
53
-
54
- OperatedRange.commit(operated_years: operated_years)
55
-
56
- Transfer::GengouScroller.set(scroll: @scroll, years: operated_years)
57
-
58
- operated_years
59
- end
60
-
61
- #
62
- # 運用結果に書き換える
63
- #
64
- # @return [Array<OperatedYear>] 運用結果範囲
65
- #
66
- def rewrite
67
- operated_years = []
68
-
69
- years.each do |year|
70
- operated_year = OperatedRange.rewrite_year(
71
- year: year,
72
- operated_solar_terms: @operated_solar_terms
73
- )
74
- operated_years.push(operated_year)
75
- end
76
-
77
- operated_years
78
- end
79
-
80
- #
81
- # 運用情報で年を跨ぐ月をその年に寄せる
82
- #
83
- # @param [Array<OperatedYear>] operated_years 運用結果範囲
84
- #
85
- def self.move(operated_years:)
86
- move_into_next_year(operated_years: operated_years)
87
- move_into_last_year(operated_years: operated_years)
88
- end
89
-
90
- #
91
- # 運用情報では来年に属する月を来年に寄せる
92
- #
93
- # @param [Array<OperatedYear>] operated_years 運用結果範囲
94
- #
95
- def self.move_into_next_year(operated_years:)
96
- operated_years.each_cons(2) do |current_year, next_year|
97
- months = current_year.pop_next_year_months
98
-
99
- next_year.unshift_months(months)
100
- end
101
- end
102
-
103
- #
104
- # 運用情報では昨年に属する月を昨年に寄せる
105
- #
106
- # @param [Array<OperatedYear>] operated_years 運用結果範囲
107
- #
108
- def self.move_into_last_year(operated_years:)
109
- rerversed_year = operated_years.reverse!
110
- rerversed_year.each_cons(2) do |current_year, last_year|
111
- months = current_year.shift_last_year_months
112
- last_year.push_months(months)
113
- end
114
-
115
- rerversed_year.reverse!
116
- end
117
-
118
- #
119
- # 年を確定させる
120
- #
121
- # @param [Array<OperatedYear>] operated_years 運用結果範囲
122
- #
123
- def self.commit(operated_years:)
124
- operated_years.each(&:commit)
125
- end
126
-
127
- #
128
- # 年を書き換える
129
- #
130
- # @param [Year] year 年
131
- # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
132
- #
133
- # @return [OperatedYear] 年
134
- #
135
- def self.rewrite_year(year:, operated_solar_terms:)
136
- context = year.context
137
- result = Base::OperatedYear.new(context: context)
138
- year.months.each do |month|
139
- result.push(month: resolve_month(
140
- context: context, month: month,
141
- operated_solar_terms: operated_solar_terms
142
- ))
143
- end
144
-
145
- result
146
- end
147
-
148
- #
149
- # 履歴情報の有無に応じた月にする
150
- #
151
- # @param [Context] context 暦コンテキスト
152
- # @param [Month] month 月
153
- # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
154
- #
155
- # @return [Month] 月
156
- #
157
- def self.resolve_month(context:, month:, operated_solar_terms:)
158
- history = Operation.specify_history(western_date: month.western_date)
159
-
160
- OperatedRange.rewrite_month(
161
- context: context, month: month, history: history,
162
- operated_solar_terms: operated_solar_terms
163
- )
164
- end
165
-
166
- # :reek:LongParameterList {max_params: 4}
167
-
168
- #
169
- # 月を運用結果に書き換える
170
- #
171
- # @param [Context] context 暦コンテキスト
172
- # @param [Month] month 月
173
- # @param [Operation::MonthHistory] history 変更履歴
174
- # @param [OperatedSolarTerms] operated_solar_terms 運用時二十四節気
175
- #
176
- # @return [Month] 月(運用結果)
177
- #
178
- def self.rewrite_month(context:, month:, history:, operated_solar_terms:)
179
- operated_month = Monthly::OperatedMonth.new(
180
- context: context,
181
- month_label: month.month_label, first_day: month.first_day,
182
- solar_terms: month.solar_terms, history: history, gengou: month.gengou,
183
- operated_solar_terms: operated_solar_terms
184
- )
185
-
186
- operated_month.rewrite unless history.invalid?
187
-
188
- operated_month
189
- end
190
- end
191
- end
192
- end
193
- end