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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3e4e967b105b46ffc94cc792328a5020aa0535f797dbf5bc5bc1a8eb2786cd8
4
- data.tar.gz: 71f0fce3e9592469062df9ef667b2e146754c79bde93647a020c942b21cf3fb1
3
+ metadata.gz: 4aab5a0f52f7180542260fa41204ea918b54601f525029e8e056efcd94cbf725
4
+ data.tar.gz: 6b72f7bbe79473ecbf0332c0f38aeea020d6cee6dfc42c667784c5ba6cb274d1
5
5
  SHA512:
6
- metadata.gz: d4acc827cebcebad50f33b3c255a23b28ebab62b05fc322ec0e304fa7d738df9479f3aded5e776e6d741d31f2c8812a30bde7ee777f3841eb140be3f44479ce8
7
- data.tar.gz: c3a8304e0afdd13b2bc31d7107594816d185114bd7b67701bc3d2f1a395cc7dfeb7c19ff653febe57fc654f8f0feaac0857a0fa2ba2db6aba5d48f2ae87231f8
6
+ metadata.gz: b990f830dd4bb46a340ae3fadfd2b303bd2a5e686351b2f4463dced260182114a5886ff35e10558d27c99752e9dae6a6bff9805e61ae635076e144341770b665
7
+ data.tar.gz: cc8546a484bba5a35049072b6a048751c9fa13a5609bd677345c9c1d69de2b41362de4695e19f3ec91b67da0de097058bcf16e618534502d1e23b4225763a05d
data/Makefile CHANGED
@@ -1,2 +1,5 @@
1
1
  binstub:
2
2
  bundle binstubs rspec-core --path exe
3
+
4
+ count:
5
+ find . -type f -name "*.rb" | xargs cat | sed "/^\s*\(#\|\$\)/d" | wc -l
data/README.md CHANGED
@@ -63,8 +63,7 @@ western_date = Date.new(862, 2, 3)
63
63
  # 初期化時の設定
64
64
  merchant = Zakuro::Merchant.new(condition: { date: western_date })
65
65
  puts merchant.commit.to_json
66
- # => {"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"
67
- 大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"}}}}
66
+ # => {"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"options":{}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"options":{}}}}
68
67
 
69
68
  western_date = Date.new(1685, 2, 3)
70
69
 
@@ -72,12 +71,12 @@ western_date = Date.new(1685, 2, 3)
72
71
  # merchant = Zakuro::Merchant.new
73
72
  merchant.offer(condition: { date: western_date })
74
73
  puts merchant.commit.to_json
75
- # => {"data":{"year":{"first_gengou":{"name":"貞享","number":1},"second_gengou":{"name":"","number":-1},"zodiac_name":"甲子","total_days":354},"month":{"number":12,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"壬辰","remainder":"28-4182","western_date":"1685-01-05"},"odd_solar_terms":[{"index":1,"remainder":"30-890"}],"even_solar_terms":[{"index":2,"remainder":"45-2726"}]},"day":{"number":30,"zodiac_name":"辛酉","remainder":"57-4182","western_date":"1685-02-03"}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞享","number":1},"second_gengou":{"name":"","number":-1},"zodiac_name":"甲子","total_days":354},"month":{"number":12,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"壬辰","remainder":"28-4182","western_date":"1685-01-05"},"odd_solar_terms":[{"index":1,"remainder":"30-890"}],"even_solar_terms":[{"index":2,"remainder":"45-2726"}]},"day":{"number":30,"zodiac_name":"辛酉","remainder":"57-4182","western_date":"1685-02-03"}}}}
74
+ # => {"data":{"year":{"first_gengou":{"name":"貞享","number":1},"second_gengou":{"name":"","number":-1},"zodiac_name":"","total_days":354},"month":{"number":12,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"壬辰","remainder":"28-4182","western_date":"1685-01-05"},"odd_solar_terms":[{"index":1,"remainder":"30-890"}],"even_solar_terms":[{"index":2,"remainder":"45-2726"}]},"day":{"number":30,"zodiac_name":"辛酉","remainder":"57-4182","western_date":"1685-02-03"},"options":{}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞享","number":1},"second_gengou":{"name":"","number":-1},"zodiac_name":"","total_days":354},"month":{"number":12,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"壬辰","remainder":"28-4182","western_date":"1685-01-05"},"odd_solar_terms":[{"index":1,"remainder":"30-890"}],"even_solar_terms":[{"index":2,"remainder":"45-2726"}]},"day":{"number":30,"zodiac_name":"辛酉","remainder":"57-4182","western_date":"1685-02-03"},"options":{}}}}
76
75
 
77
76
  # 期間検索
78
77
  merchant = Zakuro::Merchant.new(condition: { range: {start: Date.new(862, 2, 3), last: Date.new(862, 2, 4)}})
79
78
  puts merchant.commit.to_json
80
- {"list":[{"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"}}}},{"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":2,"zodiac_name":"辛未","remainder":"7-1282","western_date":"0862-02-04"}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":2,"zodiac_name":"辛未","remainder":"7-1282","western_date":"0862-02-04"}}}}]}
79
+ # => {"list":[{"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"options":{}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"options":{}}}},{"data":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":2,"zodiac_name":"辛未","remainder":"7-1282","western_date":"0862-02-04"},"options":{}},"operation":{"operated":false,"month":{"current":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]},"parent":{"id":"","western_date":"","page":-1,"number":-1,"annotations":[]}},"original":{"year":{"first_gengou":{"name":"貞観","number":4},"second_gengou":{"name":"","number":-1},"zodiac_name":"壬午","total_days":354},"month":{"number":1,"leaped":false,"days_name":"大","first_day":{"number":1,"zodiac_name":"庚午","remainder":"6-1282","western_date":"0862-02-03"},"odd_solar_terms":[{"index":5,"remainder":"34-5368"}],"even_solar_terms":[{"index":4,"remainder":"19-3532"}]},"day":{"number":2,"zodiac_name":"辛未","remainder":"7-1282","western_date":"0862-02-04"},"options":{}}}}]}
81
80
  ```
82
81
 
83
82
  # 条件
@@ -87,26 +86,36 @@ puts merchant.commit.to_json
87
86
  | 項目名 | キー名 | hash内キー名 | データ型 | 備考 |
88
87
  |----------------|---------|--------------|----------|--------------------|
89
88
  | 基準日 | date | | Date | 西暦日 |
90
- | | | | String | 和暦日 |
91
- | 範囲(開始日) | range | start | Date | |
92
- | 範囲(終了日) | | last | Date | |
89
+ | | | | String | 和暦日/西暦日 |
90
+ | 範囲(開始日) | range | start | Date | 西暦日 |
91
+ | | | | String | 和暦日/西暦日 |
92
+ | 範囲(終了日) | | last | Date | 西暦日 |
93
+ | | | | String | 和暦日/西暦日 |
93
94
  | 列 | columns | | Array | 取得したい列の列名 |
94
- | オプション | options | | Array | 取得オプション |
95
+ | オプション | options | | Hash<String, Object> | 取得オプション |
95
96
 
96
- 現時点では `date` の西暦日のみ対応中です。
97
+ 現時点では `date` と `range` のみ対応中です。
97
98
 
98
99
  ## オプション
99
100
 
100
101
  | 項目名 | キー名 | データ型 | データ | 備考 |
101
102
  |--------|-----------|----------|--------|------------------------|
102
- | 単位 | unit | String | year | 年単位 |
103
- | | | | month | 月単位 |
104
- | | | | day | 日単位(デフォルト) |
105
- | 没日 | lost_days | TRUE | | 没日あり |
106
- | | | FALSE | | 没日なし(デフォルト) |
103
+ | | version | String | Genka | 元嘉暦 |
104
+ | | | | Gihou | 儀鳳暦 |
105
+ | | | | Daien | 大衍暦 |
106
+ | | | | Senmyou | 宣明暦 |
107
+ | | | | Joukyou | 貞享暦 |
108
+ | | | | Kansei | 寛政暦 |
109
+ | | | | Tenpou | 天保暦 |
110
+ | | | | Gregorio | グレゴリオ暦 |
111
+ | | | | | 指定なし(デフォルト) |
112
+ | 没日 | dropped_days | TRUE | | 没日あり |
113
+ | | | FALSE | | 没日なし(デフォルト) |
107
114
  | 四季 | seasons | TRUE | | 四季あり |
108
115
  | | | FALSE | | 四季なし(デフォルト) |
109
116
 
117
+ 現時点では宣明暦の [没日](./doc/dropped_date.md) のみ試験的に対応しております(結果未検証)。
118
+
110
119
  # 期待値
111
120
  暦算値は『日本暦日原典』、元号の切り替えは『日本史年表 第5版』を範とします。
112
121
 
@@ -124,7 +133,7 @@ puts merchant.commit.to_json
124
133
  | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考   |
125
134
  |----------|-----------|---|---|-----------------------------------|--------|---------------------------------------|
126
135
  | 日付情報 | data | | | Zakuro::Result::Data::SingleDay | - | 運用値(計算値は運用情報内を参照のこと)|
127
- | 運用情報 | operation | | | Zakuro::Result::Operation::Bundle | - | - |
136
+ | 運用情報 | operation | | | Zakuro::Result::Operation | - | - |
128
137
 
129
138
  ### Zakuro::Result::Range
130
139
 
@@ -164,16 +173,17 @@ puts merchant.commit.to_json
164
173
  | 日の干支 | | zodiac_name | | String | 乙卯 | 日の干支 |
165
174
  | 日の大余小余 | | remainder | | String | 51-2479 | 大余小余 |
166
175
  | 西暦日 | | western_date | | String | 0937-02-14 | 西暦日 |
176
+ | オプション | options | | | Hash<String, Zakuro::Result::Data::Option::AbstractOption>| | オプション値 |
167
177
 
168
178
  ### Zakuro::Result::Operation
169
179
 
170
180
  | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
171
181
  |--------------|----------|------------|-------------|--------------------------------------------|---------|----------------------|
172
182
  | 運用有無 | operated |   |   | True/False | true |   |
173
- | 月別履歴情報 | month |   |   | Zakuro::Result::Operation::Month::Bundle |   |   |
183
+ | 月別履歴情報 | month |   |   | Zakuro::Result::Operation::Month |   |   |
174
184
  | 計算値 | original |   |   | Zakuro::Result::Data::SingleDay |   | 運用値差替前の計算値 |
175
185
 
176
- ### Zakuro::Result::Operation::Month::Bundle
186
+ ### Zakuro::Result::Operation::Month
177
187
 
178
188
  | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
179
189
  |--------------------------|----------|------------|----------|--------------------------------------------|--------------|---------------------------------------------|
@@ -193,6 +203,20 @@ puts merchant.commit.to_json
193
203
  | 注釈内容 |   | | description | String | 計算は51乙卯であるが, 日本紀略に甲寅朔とある。<br>正月甲寅朔のユリウス暦日は2月13日となる。(元旦日食 をさけるための変更か) |   |
194
204
  | 注釈補記 |   | | note | String | - | 原文訂正 |
195
205
 
206
+ ### Zakuro::Result::Data::Option::AbstractOption
207
+
208
+ #### Zakuro::Result::Data::Option::DroppedDate::Option
209
+
210
+ キー: dropped_date
211
+
212
+ | 項目名 | キー名 | - | - | データ型 | 参考値 | 備考 |
213
+ | -------------------- | ----------- | ---------- | --------- | ------------------------------------------------------ | -------- | ------------------ |
214
+ | オプション値有無 | matched | | | True/False | true | |
215
+ | 演算値 | calculation | | | Zakuro::Result::Data::Option::DroppedDate::Calculation | | |
216
+ | 没余 | | remainder | | String | 59-34155 | |
217
+ | 二十四節気 | | solar_term | | Zakuro::Result::Data::Option::DroppedDate::SolarTerm | | |
218
+ | 二十四節気番号 | | | index | Integer | 6 | |
219
+ | 二十四節気の大余小余 | | | remainder | String | 49-7203 | |
196
220
 
197
221
  # 元号
198
222
 
@@ -207,6 +231,11 @@ puts merchant.commit.to_json
207
231
 
208
232
  [宣明暦](./lib/zakuro/version/senmyou/README.md) のみ記載しております。
209
233
 
234
+ # 例外
235
+
236
+ 条件不正などで例外が発生します。
237
+ 詳細は [例外処理](./doc/error.md) を参照してください。
238
+
210
239
  ## コントリビュート(Contributing)
211
240
 
212
241
  バグ報告/修正はこちらまで。
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.8.0
@@ -0,0 +1,93 @@
1
+ # 没日
2
+ 没日を端的に説明すると、1太陽年(365.24..日)を360日で表わすために、一定の法則で `存在しない日` として配置された日である
3
+
4
+ 太陽の運行に対応するため、基本的には二十四節気をもとに計算を行う
5
+
6
+ # 期待値
7
+ 「日本暦日便覧」に従う
8
+
9
+ ## 計算
10
+ 「長慶宣明暦算法」に従う
11
+
12
+ 下記は該当箇所の引用と、それに対応する計算を示している
13
+
14
+ ```
15
+ ◯没日ヲ求ルノ術
16
+ 没日ト云ハ毎日の気盈ノ數ツモリテ統法ノ八千四百ニ満タル日ヲ云其モトメヤウノ法ナリ
17
+ ```
18
+
19
+ ```
20
+ 常氣ノ小餘六千五百六十四秒三巳上ハ物之ヲ置テ
21
+ 常氣ハ前ノ等法ニテ求メタル二十四氣トナリ其二十四節氣ノ内イツレニモ小余ノ數六千五百六十四秒三ヨリ以上アラハ没日ヲ求メヨトナリ
22
+ タトヘハ小余ノ數六千五百六十四秒アリテモ秒三ヨリ内ナラハモトムヘラカス秒ノ數ハスクナレトモ小余ノ數多クアラハ求ムヘシ
23
+ 小余ノ一ハ秒ノ八ナレハナリ
24
+ 畢竟ハ小余六千五百六十四秒三アルカ尤モソレヨリ以上アラハ求ムヘシ少シモ以下ナラハ求ムヘカラストナリ
25
+ ```
26
+
27
+ 次のパターンのみ求める
28
+ * 常気の小余 >= 6564.3
29
+
30
+ ```
31
+ 三百六十ヲ以テ之乗シ別ニ秒ヲ置テ四十五ヲ以テ之乗シ小餘ノ之上ニ加フ
32
+ 常氣ノ小余ノ數ニカクルナリ今立春ノ小余八千二百三十六秒七アリ
33
+ 故に没日ヲ求メントテマツ其立春ノ小余八千二百三十六ニ三百六十ヲカクレハ二百九十六萬四千九百六十トナル
34
+ 又別ニ秒七ヲ置テ是ニ四十五ヲカクレハ三百一十五トナル
35
+ 此ヲ右ノ二百九十六萬四千九百六十ニ加フレハ合セテ二百九十六萬五千二百七十五トナル
36
+ 又秒七ヲ八ニワリテ小余ノ次ニ置テ八千二百三十六八分七厘五毛トツテ子テ是ニ三百六十ヲカクレハ二百九十六萬五千二百七十五トナルモ同シ等法ナリ
37
+ ```
38
+
39
+ ある立春の小余: 8236.7
40
+ * A
41
+ * 8236 * 360 = 2964960
42
+ * 7 * 45 = 315
43
+ * 2964960 + 315 = 2965275
44
+ * B
45
+ * 8236 + 7/8 = 8236.875 * 360 = 2965275
46
+
47
+ ```
48
+ 而ソ章歳ノ三百零六萬八千零五十五ヲ以テ直減シ
49
+ 以ハ用ナリ置テト云心ナルヘシ此章歳ノ數三百零六萬八千零五十五ヲ置テコノ内ヲ右ノ二百九十六萬五千二百七十五去テ残テ一十萬零二千七百八十トナルナリ
50
+ 細注ニ或ハ少ヲ以テ多ニ減ストアレトモ是ハアヤマリナルヘシ
51
+ タトヘハ常氣ノ小余八千三百九十九秒七アルトキニ右ノ法ノ如クニシテミレハ三百零二萬三千九百五十五トナル
52
+ コレ章歳ノ數ニ四萬四千一百タラサルナリ
53
+ 然レハ必ラス定テ章歳ノ數ノ内ヲ減スルノ明トシ常氣ノ小余八千三百九十九秒七ヨリ多キクハナキケリ
54
+ ```
55
+ 章歳: 3068055
56
+
57
+ * 3068055 - 2965275 = 102780
58
+ * 負数はない。負数であれば正数にする
59
+
60
+ ```
61
+ 残分ヲ置テ通餘ノ四萬四千一零五十五ヲ以テ之ヲ除シ商ヲ以テ日ト為 常氣ノ之大餘ヲ加フ甲子自之ヲ命シ等外ヲ用フ也
62
+ 残分ト云ハ右ノ章歳ヲ減シタル残リ一十萬零二千七百八十トナリ此數ヲ置テ通余ノ四萬四千一零五十五ニテワレハ商ニ不盡一萬四千六百七十アリ
63
+ サテ此商二ニ常氣立春ノ大余五十六ヲ加レハ五十八トナル
64
+ コレヲ没日ノ大余ノ數トス
65
+ サテ右ノ不盡一萬四千六百七十ヲ没日ノ小余トス
66
+ 其大余ノ數モシ六十ニ満ツルトキハハラヒ去リテ其残リヲ用テサテ前ノ二十四氣ニテ攴干ヲ付タル如ク紀法ノ圖ニテ付ヘシ今大余五十八ハ壬戌ニアタルナリ
67
+ 立春一氣ノ内ニ壬戌ノ日アルヲ没日ノ日トス
68
+ サテ是ハ立春ノ一氣ヲ記セリ
69
+ 二十四氣ノ内イツレニテモ有没日ノ数小余六千五百六十四秒巳上アラハ右ノ如クニシテ求ムヘシ
70
+ ```
71
+
72
+ 通余: 44055
73
+
74
+ * 102780 / 44055 = 2.3329... ≒ 2
75
+ * 102780 % 44055 = 14670
76
+ * 56(立春大余) + 2 = 58
77
+
78
+ 没日: 58-14670
79
+
80
+ ```
81
+ 次ヲ求ルノ術
82
+ ```
83
+
84
+ ```
85
+ 大餘ニ九 小餘ニ二萬八千二百六十
86
+ 二十四氣ノ内ヲ考ヘテイツレニテモ有没日ノ小余六千五百六十四秒三以上アル時ハ右ノ法ノ如ニシテ求ムヘシ
87
+ 又一術アリモトメ得タル没日ノ大余ニ九加エ小余ニ二萬八千二百六十加エテ小余通余ノ四萬四千零五十五ニ満レハ一ニツツメテ其一ヲ大余ニ加ヘ大余六十ニ満レハ去此ノ如ク累加スレハ次々ノ没日ヲ求メ得ルナリ
88
+ 其アル日ハ有没日ノ六千五百六十四秒三以上アル處ノ氣ノ内ニアルトシルヘシ
89
+
90
+ ```
91
+ * 大余 + 9
92
+ * 小余 + 28260
93
+ * 小余 > 44055 の場合は繰り上げ
data/doc/error.md ADDED
@@ -0,0 +1,45 @@
1
+ # 例外処理
2
+
3
+ ## Zakuro::Exception::ZakuroError
4
+
5
+ 例外は `ZakuroError` に集約されます。
6
+
7
+ ```
8
+ merchant = Zakuro::Merchant.new(condition: {})
9
+ merchant.commit
10
+ Traceback (most recent call last):
11
+ 4: from ./bin/console:14:in `<main>'
12
+ 3: from (irb):5
13
+ 2: from /Users/ty/ruby/zakuro/lib/zakuro/merchant.rb:81:in `commit'
14
+ 1: from /Users/ty/ruby/zakuro/lib/zakuro/merchant.rb:132:in `make_uncommitable_error'
15
+ Zakuro::Exception::ZakuroError (an error has occurred:[{"code":"ERROR_0203","message":"検索不可能な日付指定です。"}])
16
+ ```
17
+
18
+ 例外に対応したコードとメッセージを取得できます。
19
+ ```
20
+ merchant = Zakuro::Merchant.new(condition: {})
21
+ begin
22
+ merchant.commit
23
+ rescue Zakuro::Exception::ZakuroError => e
24
+ p e.causes[0].code
25
+ p e.causes[0].message
26
+ end
27
+ => "ERROR_0203"
28
+ => "検索不可能な日付指定です。"
29
+ ```
30
+
31
+ ## エラー種別
32
+
33
+ `Zakuro::Exception::Case::Pattern` の通りです。
34
+
35
+ |コード|メッセージ|引数長|
36
+ |:----|:----|:----|
37
+ |ERROR_0001|内部エラーです。|0|
38
+ |ERROR_0101|日付の型は文字列/日付です。指定型:%s|1|
39
+ |ERROR_0102|範囲の型はhashです。指定型:%s|1|
40
+ |ERROR_0103|オプションの型はhashです。指定型:%s|1|
41
+ |ERROR_0104|列の型は配列です。指定型:%s|1|
42
+ |ERROR_0105|条件の型は配列です。指定型:%s|1|
43
+ |ERROR_0201|一日検索の日付指定が誤っています。|0|
44
+ |ERROR_0202|範囲検索の日付指定が誤っています。|0|
45
+ |ERROR_0203|検索不可能な日付指定です。|0|
@@ -39,25 +39,25 @@ table.each do |row|
39
39
  'diffs' => {
40
40
  'month' => {
41
41
  'number' => {
42
- 'calc' => month_str_to_number(row['月(計)']),
43
- 'actual' => month_str_to_number(row['月(実)'])
42
+ 'src' => month_str_to_number(row['月(計)']),
43
+ 'dest' => month_str_to_number(row['月(実)'])
44
44
  },
45
45
  'leaped' => {
46
- 'calc' => month_str_to_leaped(row['月(計)']),
47
- 'actual' => month_str_to_leaped(row['月(実)'])
46
+ 'src' => month_str_to_leaped(row['月(計)']),
47
+ 'dest' => month_str_to_leaped(row['月(実)'])
48
48
  },
49
49
  'days' => {
50
- 'calc' => row['月大小(計)'],
51
- 'actual' => row['月大小(実)']
50
+ 'src' => row['月大小(計)'],
51
+ 'dest' => row['月大小(実)']
52
52
  }
53
53
  },
54
54
  'solar_term' => {
55
- 'calc' => {
55
+ 'src' => {
56
56
  'index' => row['中気番号(計)'],
57
57
  'to' => row['中気移動先'],
58
58
  'zodiac_name' => row['中気(計)']
59
59
  },
60
- 'actual' => {
60
+ 'dest' => {
61
61
  'index' => row['中気番号(実)'],
62
62
  'from' => row['中気移動元'],
63
63
  'zodiac_name' => row['中気(実)']
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../era/western/calendar'
4
+ require_relative '../cycle/abstract_remainder'
5
+
6
+ # :nodoc:
7
+ module Zakuro
8
+ # :nodoc:
9
+ module Calculation
10
+ # :nodoc:
11
+ module Base
12
+ #
13
+ # Day 日
14
+ #
15
+ class Day
16
+ # @return [Integer] 不正日
17
+ INVALID_NUMBER = -1
18
+
19
+ # @return [Integer] 日
20
+ attr_reader :number
21
+ # @return [Western::Calendar] 西暦日
22
+ attr_reader :western_date
23
+ # @return [Cycle::AbstractRemainder] 和暦日
24
+ attr_reader :remainder
25
+
26
+ #
27
+ # 初期化
28
+ #
29
+ # @param [Integer] number 日
30
+ # @param [Western::Calendar] western_date 西暦日
31
+ # @param [Cycle::AbstractRemainder] 和暦日
32
+ #
33
+ def initialize(number: INVALID_NUMBER, western_date: Western::Calendar.new,
34
+ remainder: Cycle::AbstractRemainder.new)
35
+ @number = number
36
+ @western_date = western_date
37
+ @remainder = remainder
38
+ end
39
+
40
+ #
41
+ # 不正か
42
+ #
43
+ # @return [True] 不正
44
+ # @return [False] 不正なし
45
+ #
46
+ def invalid?
47
+ number == INVALID_NUMBER
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -45,7 +45,7 @@ module Zakuro
45
45
  # @return [LinearGengou] 1行目元号
46
46
  #
47
47
  def match_first_line(date: Western::Calendar)
48
- @first_line.each do |line|
48
+ first_line.each do |line|
49
49
  return line.clone if line.include?(date: date)
50
50
  end
51
51
 
@@ -60,13 +60,59 @@ module Zakuro
60
60
  # @return [LinearGengou] 2行目元号
61
61
  #
62
62
  def match_second_line(date: Western::Calendar)
63
- @second_line.each do |line|
63
+ second_line.each do |line|
64
64
  return line.clone if line.include?(date: date)
65
65
  end
66
66
 
67
67
  LinearGengou.new
68
68
  end
69
69
 
70
+ #
71
+ # 元号を取得する
72
+ #
73
+ # @param [String] name 元号名
74
+ #
75
+ # @return [LinearGengou] 元号
76
+ #
77
+ def match_by_name(name:)
78
+ result = match_first_line_by_name(name: name)
79
+ return result unless result.invalid?
80
+
81
+ result = match_second_line_by_name(name: name)
82
+
83
+ result
84
+ end
85
+
86
+ #
87
+ # 1行目元号を取得する
88
+ #
89
+ # @param [String] name 元号名
90
+ #
91
+ # @return [LinearGengou] 1行目元号
92
+ #
93
+ def match_first_line_by_name(name:)
94
+ first_line.each do |line|
95
+ return line.clone if line.name == name
96
+ end
97
+
98
+ LinearGengou.new
99
+ end
100
+
101
+ #
102
+ # 2行目元号を取得する
103
+ #
104
+ # @param [String] name 元号名
105
+ #
106
+ # @return [LinearGengou] 2行目元号
107
+ #
108
+ def match_second_line_by_name(name:)
109
+ second_line.each do |line|
110
+ return line.clone if line.name == name
111
+ end
112
+
113
+ LinearGengou.new
114
+ end
115
+
70
116
  #
71
117
  # 不正か
72
118
  #
@@ -74,7 +120,7 @@ module Zakuro
74
120
  # @return [False] 不正なし
75
121
  #
76
122
  def invalid?
77
- @first_line.size.zero? && @second_line.size.zero?
123
+ first_line.size.zero? && second_line.size.zero?
78
124
  end
79
125
  end
80
126
  end
@@ -46,7 +46,7 @@ module Zakuro
46
46
  # @return [False] 不正なし
47
47
  #
48
48
  def invalid?
49
- @name == '' || @year == INVALID_YEAR
49
+ name == '' || year == INVALID_YEAR
50
50
  end
51
51
 
52
52
  #
@@ -60,13 +60,13 @@ module Zakuro
60
60
  def include?(date: Western::Calendar.new)
61
61
  return false if invalid?
62
62
 
63
- return false if @start_date.invalid?
63
+ return false if start_date.invalid?
64
64
 
65
- return false if @last_date.invalid?
65
+ return false if last_date.invalid?
66
66
 
67
- return false if date < @start_date
67
+ return false if date < start_date
68
68
 
69
- return false if date > @last_date
69
+ return false if date > last_date
70
70
 
71
71
  true
72
72
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative './year'
4
4
 
5
- require_relative '../../version/context'
5
+ require_relative '../../context/context'
6
6
 
7
7
  # :nodoc:
8
8
  module Zakuro
@@ -17,11 +17,11 @@ module Zakuro
17
17
  #
18
18
  # 初期化
19
19
  #
20
- # @param [Context] context 暦コンテキスト
20
+ # @param [Context::Context] context 暦コンテキスト
21
21
  # @param [Array<OperatedMonth>] months 年内の全ての月
22
22
  # @param [Integer] total_days 年の日数
23
23
  #
24
- def initialize(context: Context.new, months: [], total_days: 0)
24
+ def initialize(context: Context::Context.new, months: [], total_days: 0)
25
25
  super(context: context, months: months, total_days: total_days)
26
26
  end
27
27
 
@@ -56,7 +56,7 @@ module Zakuro
56
56
  # @return [Array<OperatedMonth>] 昨年に属する月
57
57
  #
58
58
  def shift_last_year_months
59
- result, @months = OperatedYear.devide_with(method: :last_year?, arr: months)
59
+ result, @months = self.class.devide_with(method: :last_year?, arr: months)
60
60
 
61
61
  result
62
62
  end
@@ -67,36 +67,38 @@ module Zakuro
67
67
  # @return [Array<OperatedMonth>] 来年に属する月
68
68
  #
69
69
  def pop_next_year_months
70
- result, @months = OperatedYear.devide_with(method: :next_year?, arr: months)
70
+ result, @months = self.class.devide_with(method: :next_year?, arr: months)
71
71
 
72
72
  result
73
73
  end
74
74
 
75
75
  # :reek:TooManyStatements { max_statements: 8 }
76
76
 
77
- #
78
- # メソッドで配列を分離する
79
- #
80
- # @param [Symbol] method 条件メソッド
81
- # @param [Array<Object>] arr 配列
82
- #
83
- # @return [Array<Object>] 一致配列
84
- # @return [Array<Object>] 不一致配列
85
- #
86
- def self.devide_with(method:, arr: [])
87
- match = []
88
- unmatch = []
77
+ class << self
78
+ #
79
+ # メソッドで配列を分離する
80
+ #
81
+ # @param [Symbol] method 条件メソッド
82
+ # @param [Array<Object>] arr 配列
83
+ #
84
+ # @return [Array<Object>] 一致配列
85
+ # @return [Array<Object>] 不一致配列
86
+ #
87
+ def devide_with(method:, arr: [])
88
+ match = []
89
+ unmatch = []
90
+
91
+ arr.each do |item|
92
+ if !item.moved? && item.send(method)
93
+ match.push(item)
94
+ next
95
+ end
89
96
 
90
- arr.each do |item|
91
- if !item.moved? && item.send(method)
92
- match.push(item)
93
- next
97
+ unmatch.push(item)
94
98
  end
95
99
 
96
- unmatch.push(item)
100
+ [match, unmatch]
97
101
  end
98
-
99
- [match, unmatch]
100
102
  end
101
103
  end
102
104
  end