zakuro 0.9.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/README.md +41 -8
  4. data/VERSION +1 -1
  5. data/doc/gengou.md +1 -1
  6. data/doc/operation/csv/month.csv +8 -9
  7. data/doc/operation/operation.xlsx +0 -0
  8. data/images/logo-text.png +0 -0
  9. data/lib/zakuro/calculation/base/gengou.rb +2 -4
  10. data/lib/zakuro/calculation/base/year.rb +1 -1
  11. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +6 -0
  12. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +2 -2
  13. data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +4 -2
  14. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +1 -1
  15. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +13 -7
  16. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +18 -9
  17. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +6 -2
  18. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +5 -2
  19. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +3 -3
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +12 -4
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +10 -4
  22. data/lib/zakuro/calculation/era/gengou/named_scroll.rb +5 -2
  23. data/lib/zakuro/calculation/era/version/internal/crawler.rb +3 -3
  24. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +1 -1
  25. data/lib/zakuro/calculation/monthly/internal/date_comparer.rb +78 -0
  26. data/lib/zakuro/calculation/monthly/{meta → internal/meta}/all_solar_term.rb +1 -1
  27. data/lib/zakuro/calculation/monthly/{meta → internal/meta}/meta_collector.rb +2 -2
  28. data/lib/zakuro/calculation/monthly/{first_day.rb → internal/part/first_day.rb} +2 -2
  29. data/lib/zakuro/calculation/monthly/{meta.rb → internal/part/meta.rb} +1 -1
  30. data/lib/zakuro/calculation/monthly/internal/solar_term_selector.rb +203 -0
  31. data/lib/zakuro/calculation/monthly/month.rb +38 -74
  32. data/lib/zakuro/calculation/monthly/operated_month.rb +7 -2
  33. data/lib/zakuro/calculation/option/dropped_date/location.rb +8 -1
  34. data/lib/zakuro/calculation/range/dated_full_range.rb +6 -3
  35. data/lib/zakuro/calculation/range/dated_operation_range.rb +2 -1
  36. data/lib/zakuro/calculation/range/medieval_annual_range.rb +0 -2
  37. data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
  38. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +24 -10
  39. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +3 -3
  40. data/lib/zakuro/calculation/summary/internal/option/dropped_date.rb +102 -0
  41. data/lib/zakuro/calculation/summary/internal/option/vanished_date.rb +111 -0
  42. data/lib/zakuro/calculation/summary/internal/option.rb +4 -137
  43. data/lib/zakuro/calculation/summary/japan/range.rb +4 -5
  44. data/lib/zakuro/calculation/summary/western/range.rb +8 -1
  45. data/lib/zakuro/calculation/summary/western/single.rb +10 -5
  46. data/lib/zakuro/context/version_class_resolver.rb +5 -5
  47. data/lib/zakuro/era/japan/calendar.rb +4 -4
  48. data/lib/zakuro/era/japan/gengou/alignment/division.rb +2 -2
  49. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +2 -2
  50. data/lib/zakuro/era/japan/gengou/alignment.rb +35 -6
  51. data/lib/zakuro/era/japan/gengou/resource/parser.rb +17 -16
  52. data/lib/zakuro/era/japan/gengou/resource/validator.rb +3 -394
  53. data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +2 -2
  54. data/lib/zakuro/era/japan/gengou.rb +8 -6
  55. data/lib/zakuro/era/japan/type/base/both/date.rb +51 -0
  56. data/lib/zakuro/era/japan/type/base/both/year.rb +53 -0
  57. data/lib/zakuro/era/japan/type/base/gengou.rb +177 -0
  58. data/lib/zakuro/era/japan/type/base/gengou_set.rb +78 -0
  59. data/lib/zakuro/era/japan/type/base/switch_date.rb +74 -0
  60. data/lib/zakuro/era/japan/type/base/version_range.rb +189 -0
  61. data/lib/zakuro/era/japan/type/validation/both/date.rb +99 -0
  62. data/lib/zakuro/era/japan/type/validation/both/year.rb +75 -0
  63. data/lib/zakuro/era/japan/type/validation/gengou.rb +93 -0
  64. data/lib/zakuro/era/japan/type/validation/gengou_set.rb +133 -0
  65. data/lib/zakuro/era/japan/type/validation/switch_date.rb +73 -0
  66. data/lib/zakuro/era/japan/type/validation/version_range.rb +109 -0
  67. data/lib/zakuro/era/japan/type/validation/version_root.rb +102 -0
  68. data/lib/zakuro/era/japan/version/resource/parser.rb +266 -0
  69. data/lib/zakuro/era/japan/version/resource/validator.rb +37 -0
  70. data/lib/zakuro/era/japan/version/resource/yaml/version.yaml +80 -0
  71. data/lib/zakuro/era/japan/version/resource.rb +22 -0
  72. data/lib/zakuro/era/japan/version.rb +4 -115
  73. data/lib/zakuro/era/western/calendar.rb +2 -2
  74. data/lib/zakuro/exception/zakuro_error.rb +1 -1
  75. data/lib/zakuro/merchant.rb +5 -5
  76. data/lib/zakuro/operation/month/parser.rb +2 -2
  77. data/lib/zakuro/operation/yaml/month.yaml +8 -40
  78. data/lib/zakuro/output/logger.rb +4 -4
  79. data/lib/zakuro/parameter/catalog/basis_date.rb +55 -0
  80. data/lib/zakuro/parameter/catalog/column.rb +57 -0
  81. data/lib/zakuro/parameter/catalog/option.rb +60 -0
  82. data/lib/zakuro/parameter/catalog/range.rb +81 -0
  83. data/lib/zakuro/parameter/condition.rb +108 -0
  84. data/lib/zakuro/result/core.rb +2 -2
  85. data/lib/zakuro/{tools → tool}/remainder_comparer.rb +3 -2
  86. data/lib/zakuro/{tools → tool}/stringifier.rb +3 -3
  87. data/lib/zakuro/{tools → tool}/typeconv.rb +2 -2
  88. data/lib/zakuro/{tools → tool}/typeof.rb +2 -2
  89. data/lib/zakuro/version/daien/const/number.rb +42 -39
  90. data/lib/zakuro/version/daien/const/remainder.rb +38 -35
  91. data/lib/zakuro/version/daien/cycle/remainder.rb +77 -74
  92. data/lib/zakuro/version/daien/cycle/solar_term.rb +18 -15
  93. data/lib/zakuro/version/daien/daien.rb +8 -5
  94. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +67 -64
  95. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +15 -12
  96. data/lib/zakuro/version/daien/option/vanished_date/parameter.rb +15 -12
  97. data/lib/zakuro/version/daien/range/annual_range.rb +27 -24
  98. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +209 -206
  99. data/lib/zakuro/version/daien/stella/lunar/localization.rb +32 -29
  100. data/lib/zakuro/version/daien/stella/lunar/location.rb +53 -50
  101. data/lib/zakuro/version/daien/stella/lunar/value.rb +65 -62
  102. data/lib/zakuro/version/daien/stella/origin/average_november.rb +23 -20
  103. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +42 -39
  104. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +44 -41
  105. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +74 -71
  106. data/lib/zakuro/version/daien/stella/solar/average.rb +68 -65
  107. data/lib/zakuro/version/daien/stella/solar/interval.rb +95 -92
  108. data/lib/zakuro/version/daien/stella/solar/location.rb +41 -38
  109. data/lib/zakuro/version/daien/stella/solar/value.rb +21 -18
  110. data/lib/zakuro/version/genka/const/number.rb +31 -28
  111. data/lib/zakuro/version/genka/const/remainder.rb +20 -17
  112. data/lib/zakuro/version/genka/cycle/remainder.rb +72 -69
  113. data/lib/zakuro/version/genka/cycle/solar_term.rb +18 -15
  114. data/lib/zakuro/version/genka/genka.rb +8 -5
  115. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +82 -79
  116. data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +13 -10
  117. data/lib/zakuro/version/genka/option/vanished_date/parameter.rb +13 -10
  118. data/lib/zakuro/version/genka/range/annual_range.rb +57 -54
  119. data/lib/zakuro/version/genka/stella/origin/first_term.rb +44 -41
  120. data/lib/zakuro/version/genka/stella/origin/january.rb +38 -35
  121. data/lib/zakuro/version/genka/stella/solar/average.rb +24 -21
  122. data/lib/zakuro/version/gihou/const/number.rb +40 -37
  123. data/lib/zakuro/version/gihou/const/remainder.rb +32 -29
  124. data/lib/zakuro/version/gihou/cycle/remainder.rb +38 -35
  125. data/lib/zakuro/version/gihou/cycle/solar_term.rb +18 -15
  126. data/lib/zakuro/version/gihou/gihou.rb +8 -5
  127. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +68 -65
  128. data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +13 -10
  129. data/lib/zakuro/version/gihou/option/vanished_date/parameter.rb +13 -10
  130. data/lib/zakuro/version/gihou/range/annual_range.rb +27 -24
  131. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +212 -209
  132. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +32 -29
  133. data/lib/zakuro/version/gihou/stella/lunar/location.rb +53 -50
  134. data/lib/zakuro/version/gihou/stella/lunar/value.rb +65 -62
  135. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +23 -20
  136. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +42 -39
  137. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +44 -41
  138. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +74 -71
  139. data/lib/zakuro/version/gihou/stella/solar/average.rb +67 -64
  140. data/lib/zakuro/version/gihou/stella/solar/interval.rb +95 -92
  141. data/lib/zakuro/version/gihou/stella/solar/location.rb +41 -38
  142. data/lib/zakuro/version/gihou/stella/solar/value.rb +21 -18
  143. data/lib/zakuro/version/gregorio/gregorio.rb +8 -5
  144. data/lib/zakuro/version/houryaku/houryaku.rb +8 -5
  145. data/lib/zakuro/version/joukyou/joukyou.rb +8 -5
  146. data/lib/zakuro/version/kansei/kansei.rb +8 -5
  147. data/lib/zakuro/version/senmyou/const/number.rb +40 -37
  148. data/lib/zakuro/version/senmyou/const/remainder.rb +35 -32
  149. data/lib/zakuro/version/senmyou/cycle/remainder.rb +74 -71
  150. data/lib/zakuro/version/senmyou/cycle/solar_term.rb +18 -15
  151. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +69 -66
  152. data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +15 -12
  153. data/lib/zakuro/version/senmyou/option/vanished_date/parameter.rb +15 -12
  154. data/lib/zakuro/version/senmyou/range/annual_range.rb +27 -24
  155. data/lib/zakuro/version/senmyou/senmyou.rb +8 -5
  156. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +206 -203
  157. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +32 -29
  158. data/lib/zakuro/version/senmyou/stella/lunar/location.rb +60 -57
  159. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +66 -63
  160. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +23 -20
  161. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +42 -39
  162. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +44 -41
  163. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +74 -71
  164. data/lib/zakuro/version/senmyou/stella/solar/average.rb +67 -64
  165. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +93 -90
  166. data/lib/zakuro/version/senmyou/stella/solar/location.rb +41 -38
  167. data/lib/zakuro/version/senmyou/stella/solar/value.rb +23 -20
  168. data/lib/zakuro/version/tenpou/tenpou.rb +8 -5
  169. metadata +40 -15
  170. data/lib/zakuro/condition.rb +0 -306
  171. data/lib/zakuro/era/japan/gengou/resource/type.rb +0 -356
  172. /data/lib/zakuro/calculation/monthly/{operated_solar_term.rb → internal/operated_solar_term.rb} +0 -0
  173. /data/lib/zakuro/calculation/monthly/{const.rb → internal/part/const.rb} +0 -0
  174. /data/lib/zakuro/calculation/monthly/{month_label.rb → internal/part/month_label.rb} +0 -0
@@ -9,69 +9,72 @@ require_relative './adjustment'
9
9
  # :nodoc:
10
10
  module Zakuro
11
11
  # :nodoc:
12
- module Gihou
12
+ module Version
13
13
  # :nodoc:
14
- module Lunar
15
- #
16
- # Value 月補正値
17
- #
18
- module Value
19
- # @return [Output::Logger] ロガー
20
- LOGGER = Output::Logger.new(location: 'lunar_value')
21
-
22
- # :reek:TooManyStatements { max_statements: 9 }
23
-
24
- class << self
25
- #
26
- # 月の運行による補正値を算出する
27
- #
28
- # @param [Cycle::LunarRemainder] remainder 月の大余小余
29
- #
30
- # @return [Integer] 補正値
31
- #
32
- def get(remainder:)
33
- valid?(remainder: remainder)
34
-
35
- day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
36
- remainder: remainder
37
- )
38
-
39
- # 引き当て
40
- row = Adjustment.specify(day: day, minute: minute)
41
-
42
- value = row.value
43
-
44
- # LOGGER.debug("value.per: #{value.per}")
45
- # LOGGER.debug("row.denominator: #{row.denominator}")
46
- # LOGGER.debug("value.stack: #{value.stack}")
47
-
48
- minus_minute = Adjustment.minus_minute(day: day, minute: minute)
49
-
50
- day = Calculation::Lunar::ChoukeiValue.rounded_day(
51
- per: value.per, denominator: row.denominator, minute: minus_minute
52
- )
53
-
54
- # LOGGER.debug("day: #{day}")
55
-
56
- value.stack + day
57
- end
58
-
59
- private
60
-
61
- #
62
- # 大余小余を検証する
63
- #
64
- # @param [Cycle::LunarRemainder] remainder 大余小余
65
- #
66
- # @return [True] 正しい(月の位相計算に使う大余小余)
67
- # @return [True] 正しくない
68
- #
69
- # @raise [ArgumentError] 引数エラー
70
- #
71
- def valid?(remainder:)
72
- return if remainder.is_a?(Cycle::LunarRemainder)
73
-
74
- raise ArgumentError, "unmatch parameter type: #{remainder.class}"
14
+ module Gihou
15
+ # :nodoc:
16
+ module Lunar
17
+ #
18
+ # Value 月補正値
19
+ #
20
+ module Value
21
+ # @return [Output::Logger] ロガー
22
+ LOGGER = Output::Logger.new(location: 'lunar_value')
23
+
24
+ # :reek:TooManyStatements { max_statements: 9 }
25
+
26
+ class << self
27
+ #
28
+ # 月の運行による補正値を算出する
29
+ #
30
+ # @param [Cycle::LunarRemainder] remainder 月の大余小余
31
+ #
32
+ # @return [Integer] 補正値
33
+ #
34
+ def get(remainder:)
35
+ valid?(remainder: remainder)
36
+
37
+ day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
38
+ remainder: remainder
39
+ )
40
+
41
+ # 引き当て
42
+ row = Adjustment.specify(day: day, minute: minute)
43
+
44
+ value = row.value
45
+
46
+ # LOGGER.debug("value.per: #{value.per}")
47
+ # LOGGER.debug("row.denominator: #{row.denominator}")
48
+ # LOGGER.debug("value.stack: #{value.stack}")
49
+
50
+ minus_minute = Adjustment.minus_minute(day: day, minute: minute)
51
+
52
+ day = Calculation::Lunar::ChoukeiValue.rounded_day(
53
+ per: value.per, denominator: row.denominator, minute: minus_minute
54
+ )
55
+
56
+ # LOGGER.debug("day: #{day}")
57
+
58
+ value.stack + day
59
+ end
60
+
61
+ private
62
+
63
+ #
64
+ # 大余小余を検証する
65
+ #
66
+ # @param [Cycle::LunarRemainder] remainder 大余小余
67
+ #
68
+ # @return [True] 正しい(月の位相計算に使う大余小余)
69
+ # @return [True] 正しくない
70
+ #
71
+ # @raise [ArgumentError] 引数エラー
72
+ #
73
+ def valid?(remainder:)
74
+ return if remainder.is_a?(Cycle::LunarRemainder)
75
+
76
+ raise ArgumentError, "unmatch parameter type: #{remainder.class}"
77
+ end
75
78
  end
76
79
  end
77
80
  end
@@ -6,28 +6,31 @@ require_relative './winter_solstice'
6
6
  # :nodoc:
7
7
  module Zakuro
8
8
  # :nodoc:
9
- module Gihou
9
+ module Version
10
10
  # :nodoc:
11
- module Origin
12
- #
13
- # AverageNovember 11月経
14
- #
15
- module AverageNovember
16
- class << self
17
- #
18
- # 11月経朔(冬至が含まれる月の1日)を求める
19
- #
20
- # @param [Integer] western_year 西暦年
21
- #
22
- # @return [Remainder] 11月経朔
23
- #
24
- def get(western_year:)
25
- # 冬至
26
- winter_solstice = WinterSolstice.get(western_year: western_year)
27
- # 天正閏余
28
- lunar_age = LunarAge.get(western_year: western_year)
11
+ module Gihou
12
+ # :nodoc:
13
+ module Origin
14
+ #
15
+ # AverageNovember 11月経
16
+ #
17
+ module AverageNovember
18
+ class << self
19
+ #
20
+ # 11月経朔(冬至が含まれる月の1日)を求める
21
+ #
22
+ # @param [Integer] western_year 西暦年
23
+ #
24
+ # @return [Remainder] 11月経朔
25
+ #
26
+ def get(western_year:)
27
+ # 冬至
28
+ winter_solstice = WinterSolstice.get(western_year: western_year)
29
+ # 天正閏余
30
+ lunar_age = LunarAge.get(western_year: western_year)
29
31
 
30
- winter_solstice.sub(lunar_age)
32
+ winter_solstice.sub(lunar_age)
33
+ end
31
34
  end
32
35
  end
33
36
  end
@@ -7,55 +7,58 @@ require_relative '../../const/number'
7
7
  # :nodoc:
8
8
  module Zakuro
9
9
  # :nodoc:
10
- module Gihou
10
+ module Version
11
11
  # :nodoc:
12
- module Origin
13
- #
14
- # LunarAge 天正閏余
15
- #
16
- module LunarAge
17
- # @return [Integer] 朔望月
18
- SYNODIC_MONTH = Const::Number::Cycle::SYNODIC_MONTH
19
- # @return [Integer] 一年
20
- YEAR = Const::Number::Cycle::YEAR
21
- # @return [Integer] 積年
22
- TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
23
- # @return [Integer] 暦の開始年
24
- BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
12
+ module Gihou
13
+ # :nodoc:
14
+ module Origin
15
+ #
16
+ # LunarAge 天正閏余
17
+ #
18
+ module LunarAge
19
+ # @return [Integer] 朔望月
20
+ SYNODIC_MONTH = Const::Number::Cycle::SYNODIC_MONTH
21
+ # @return [Integer] 一年
22
+ YEAR = Const::Number::Cycle::YEAR
23
+ # @return [Integer] 積年
24
+ TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
25
+ # @return [Integer] 暦の開始年
26
+ BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
25
27
 
26
- # @return [Output::Logger] ロガー
27
- LOGGER = Output::Logger.new(location: 'lunar_age')
28
+ # @return [Output::Logger] ロガー
29
+ LOGGER = Output::Logger.new(location: 'lunar_age')
28
30
 
29
- # :reek:TooManyStatements { max_statements: 7 }
31
+ # :reek:TooManyStatements { max_statements: 7 }
30
32
 
31
- class << self
32
- #
33
- # 対象年の天正閏余(冬至より前にある11月経朔との差 = 月齢)を算出する
34
- # 太陽と月の運動による補正値を算出し、その補正結果を返す
35
- #
36
- # @param [Integer] western_year 西暦年
37
- #
38
- # @return [Remainder] 天正閏余
39
- #
40
- def get(western_year:)
41
- # 積年の開始から対象年までの年数
42
- total = TOTAL_YEAR + western_year - BEGIN_YEAR
33
+ class << self
34
+ #
35
+ # 対象年の天正閏余(冬至より前にある11月経朔との差 = 月齢)を算出する
36
+ # 太陽と月の運動による補正値を算出し、その補正結果を返す
37
+ #
38
+ # @param [Integer] western_year 西暦年
39
+ #
40
+ # @return [Remainder] 天正閏余
41
+ #
42
+ def get(western_year:)
43
+ # 積年の開始から対象年までの年数
44
+ total = TOTAL_YEAR + western_year - BEGIN_YEAR
43
45
 
44
- # 12朔望月に対する1年の余り(単位:分)
45
- remainder_minute = YEAR - (SYNODIC_MONTH * 12)
46
+ # 12朔望月に対する1年の余り(単位:分)
47
+ remainder_minute = YEAR - (SYNODIC_MONTH * 12)
46
48
 
47
- # 朔望月に含まれなかった余り(単位:年)
48
- remainder_year = total % SYNODIC_MONTH
49
+ # 朔望月に含まれなかった余り(単位:年)
50
+ remainder_year = total % SYNODIC_MONTH
49
51
 
50
- LOGGER.debug("[01]: #{remainder_year}")
52
+ LOGGER.debug("[01]: #{remainder_year}")
51
53
 
52
- # 天正閏余
53
- lunar_age = remainder_minute * remainder_year % SYNODIC_MONTH
54
+ # 天正閏余
55
+ lunar_age = remainder_minute * remainder_year % SYNODIC_MONTH
54
56
 
55
- LOGGER.debug("[02]: #{lunar_age}")
57
+ LOGGER.debug("[02]: #{lunar_age}")
56
58
 
57
- # 大余・小余に変換する
58
- Cycle::Remainder.new(total: lunar_age)
59
+ # 大余・小余に変換する
60
+ Cycle::Remainder.new(total: lunar_age)
61
+ end
59
62
  end
60
63
  end
61
64
  end
@@ -7,48 +7,51 @@ require_relative '../../const/number'
7
7
  # :nodoc:
8
8
  module Zakuro
9
9
  # :nodoc:
10
- module Gihou
10
+ module Version
11
11
  # :nodoc:
12
- module Origin
13
- #
14
- # WinterSolstice 冬至
15
- #
16
- module WinterSolstice
17
- # @return [Integer] 通余
18
- REMAINDER_ALL_YEAR = Const::Number::Derivation::REMAINDER_ALL_YEAR
19
- # @return [Integer] 60日
20
- SIXTY_DAYS = Const::Number::Derivation::SIXTY_DAYS
21
- # @return [Integer] 積年
22
- TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
23
- # @return [Integer] 暦の開始年
24
- BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
25
-
26
- # @return [Output::Logger] ロガー
27
- LOGGER = Output::Logger.new(location: 'winter_solstice')
28
-
29
- class << self
30
- # :reek:TooManyStatements { max_statements: 6 }
31
-
32
- #
33
- # 対象年の前年の冬至を求める
34
- #
35
- # @param [Integer] western_year 西暦年
36
- #
37
- # @return [Remainder] 前年の冬至
38
- #
39
- def get(western_year:)
40
- # 積年の開始から対象年までの年数
41
- total = TOTAL_YEAR + western_year - BEGIN_YEAR
42
- remainder_year = total % SIXTY_DAYS
43
-
44
- LOGGER.debug("[01]:#{remainder_year}")
45
-
46
- # 通余を使う
47
- winter_solstice_minute = (remainder_year * REMAINDER_ALL_YEAR) % SIXTY_DAYS
48
-
49
- LOGGER.debug("[02]:#{winter_solstice_minute}")
50
-
51
- Cycle::Remainder.new(total: winter_solstice_minute)
12
+ module Gihou
13
+ # :nodoc:
14
+ module Origin
15
+ #
16
+ # WinterSolstice 冬至
17
+ #
18
+ module WinterSolstice
19
+ # @return [Integer] 通余
20
+ REMAINDER_ALL_YEAR = Const::Number::Derivation::REMAINDER_ALL_YEAR
21
+ # @return [Integer] 60日
22
+ SIXTY_DAYS = Const::Number::Derivation::SIXTY_DAYS
23
+ # @return [Integer] 積年
24
+ TOTAL_YEAR = Const::Number::Stack::TOTAL_YEAR
25
+ # @return [Integer] 暦の開始年
26
+ BEGIN_YEAR = Const::Number::Stack::BEGIN_YEAR
27
+
28
+ # @return [Output::Logger] ロガー
29
+ LOGGER = Output::Logger.new(location: 'winter_solstice')
30
+
31
+ class << self
32
+ # :reek:TooManyStatements { max_statements: 6 }
33
+
34
+ #
35
+ # 対象年の前年の冬至を求める
36
+ #
37
+ # @param [Integer] western_year 西暦年
38
+ #
39
+ # @return [Remainder] 前年の冬至
40
+ #
41
+ def get(western_year:)
42
+ # 積年の開始から対象年までの年数
43
+ total = TOTAL_YEAR + western_year - BEGIN_YEAR
44
+ remainder_year = total % SIXTY_DAYS
45
+
46
+ LOGGER.debug("[01]:#{remainder_year}")
47
+
48
+ # 通余を使う
49
+ winter_solstice_minute = (remainder_year * REMAINDER_ALL_YEAR) % SIXTY_DAYS
50
+
51
+ LOGGER.debug("[02]:#{winter_solstice_minute}")
52
+
53
+ Cycle::Remainder.new(total: winter_solstice_minute)
54
+ end
52
55
  end
53
56
  end
54
57
  end
@@ -7,86 +7,89 @@ require_relative '../../const/number'
7
7
  # :nodoc:
8
8
  module Zakuro
9
9
  # :nodoc:
10
- module Gihou
10
+ module Version
11
11
  # :nodoc:
12
- module Solar
13
- #
14
- # Adjustment 24気損益眺朒(ちょうじく)数
15
- #
16
- module Adjustment
12
+ module Gihou
13
+ # :nodoc:
14
+ module Solar
17
15
  #
18
- # Row 行データ
16
+ # Adjustment 24気損益眺朒(ちょうじく)数
19
17
  #
20
- class Row
21
- # @return [Integer] 眺朒(ちょうじく)積
22
- attr_reader :stack
23
- # @return [Integer] 眺朒(ちょうじく)数
24
- attr_reader :per_term
25
- # @return [Integer] 毎日差
26
- attr_reader :per_day
27
-
28
- #
29
- # 初期化
18
+ module Adjustment
30
19
  #
31
- # @param [Integer] stack 眺朒(ちょうじく)積
32
- # @param [Integer] per_term 眺朒(ちょうじく)数
33
- # @param [Integer] per_day 毎日差
20
+ # Row 行データ
34
21
  #
35
- def initialize(stack:, per_term:, per_day:)
36
- @stack = stack
37
- @per_term = per_term
38
- @per_day = per_day
39
- end
22
+ class Row
23
+ # @return [Integer] 眺朒(ちょうじく)積
24
+ attr_reader :stack
25
+ # @return [Integer] 眺朒(ちょうじく)数
26
+ attr_reader :per_term
27
+ # @return [Integer] 毎日差
28
+ attr_reader :per_day
40
29
 
41
- #
42
- # 文字化
43
- #
44
- # @return [String] 文字
45
- #
46
- def to_s
47
- "stack:#{@stack}, per_term:#{@per_term}, per_day:#{@per_day}"
30
+ #
31
+ # 初期化
32
+ #
33
+ # @param [Integer] stack 眺朒(ちょうじく)積
34
+ # @param [Integer] per_term 眺朒(ちょうじく)数
35
+ # @param [Integer] per_day 毎日差
36
+ #
37
+ def initialize(stack:, per_term:, per_day:)
38
+ @stack = stack
39
+ @per_term = per_term
40
+ @per_day = per_day
41
+ end
42
+
43
+ #
44
+ # 文字化
45
+ #
46
+ # @return [String] 文字
47
+ #
48
+ def to_s
49
+ "stack:#{@stack}, per_term:#{@per_term}, per_day:#{@per_day}"
50
+ end
48
51
  end
49
- end
50
52
 
51
- # @return [Array<Row>] 24気損益眺朒(ちょうじく)数
52
- MAP = {
53
- touji: Row.new(stack: 0.0, per_term: +3.9546, per_day: -0.0372), # 冬至(とうじ)
54
- shoukan: Row.new(stack: +54.0, per_term: +3.4091, per_day: -0.0372), # 小寒(しょうかん)
55
- daikan: Row.new(stack: +100.0, per_term: +2.8636, per_day: -0.0372), # 大寒(だいかん)
56
- risshun: Row.new(stack: +138.0, per_term: +2.3181, per_day: +0.0372), # 立春(りっしゅん)
57
- usui: Row.new(stack: +176.0, per_term: +2.8636, per_day: +0.0372), # 雨水(うすい)
58
- keichitsu: Row.new(stack: +222.0, per_term: +3.4091, per_day: +0.0372), # 啓蟄(けいちつ)
59
- shunbun: Row.new(stack: +276.0, per_term: -3.7220, per_day: +0.0329), # 春分(しゅんぶん)
60
- seimei: Row.new(stack: +222.0, per_term: -3.2086, per_day: +0.0329), # 清明(せいめい)
61
- kokuu: Row.new(stack: +176.0, per_term: -2.6952, per_day: +0.0329), # 穀雨(こくう)
62
- rikka: Row.new(stack: +138.0, per_term: -2.1818, per_day: -0.0329), # 立夏(りっか)
63
- shouman: Row.new(stack: +100.0, per_term: -2.6952, per_day: -0.0329), # 小満(しょうまん)
64
- boushu: Row.new(stack: +54.0, per_term: -3.2086, per_day: -0.0329), # 芒種(ぼうしゅ)
65
- geshi: Row.new(stack: 0.0, per_term: -3.7220, per_day: +0.0329), # 夏至(げし)
66
- shousho: Row.new(stack: -54.0, per_term: -3.2086, per_day: +0.0329), # 小暑(しょうしょ)
67
- taisho: Row.new(stack: -100.0, per_term: -2.6952, per_day: +0.0329), # 大暑(たいしょ)
68
- risshuu: Row.new(stack: -138.0, per_term: -2.1818, per_day: -0.0329), # 立秋(りっしゅう)
69
- shosho: Row.new(stack: -176.0, per_term: -2.6952, per_day: -0.0329), # 処暑(しょしょ)
70
- hakuro: Row.new(stack: -222.0, per_term: -3.2086, per_day: -0.0329), # 白露(はくろ)
71
- shuubun: Row.new(stack: -276.0, per_term: +3.9546, per_day: -0.0372), # 秋分(しゅうぶん)
72
- kanro: Row.new(stack: -222.0, per_term: +3.4091, per_day: -0.0372), # 寒露(かんろ)
73
- soukou: Row.new(stack: -176.0, per_term: +2.8636, per_day: -0.0372), # 霜降(そうこう)
74
- rittou: Row.new(stack: -138.0, per_term: +2.3181, per_day: +0.0372), # 立冬(りっとう)
75
- shousetsu: Row.new(stack: -100.0, per_term: +2.8636, per_day: +0.0372), # 小雪(しょうせつ)
76
- taisetsu: Row.new(stack: -54.0, per_term: +3.4091, per_day: +0.0372) # 大雪(たいせつ)
77
- }.freeze
53
+ # @return [Array<Row>] 24気損益眺朒(ちょうじく)数
54
+ MAP = {
55
+ touji: Row.new(stack: 0.0, per_term: +3.9546, per_day: -0.0372), # 冬至(とうじ)
56
+ shoukan: Row.new(stack: +54.0, per_term: +3.4091, per_day: -0.0372), # 小寒(しょうかん)
57
+ daikan: Row.new(stack: +100.0, per_term: +2.8636, per_day: -0.0372), # 大寒(だいかん)
58
+ risshun: Row.new(stack: +138.0, per_term: +2.3181, per_day: +0.0372), # 立春(りっしゅん)
59
+ usui: Row.new(stack: +176.0, per_term: +2.8636, per_day: +0.0372), # 雨水(うすい)
60
+ keichitsu: Row.new(stack: +222.0, per_term: +3.4091, per_day: +0.0372), # 啓蟄(けいちつ)
61
+ shunbun: Row.new(stack: +276.0, per_term: -3.7220, per_day: +0.0329), # 春分(しゅんぶん)
62
+ seimei: Row.new(stack: +222.0, per_term: -3.2086, per_day: +0.0329), # 清明(せいめい)
63
+ kokuu: Row.new(stack: +176.0, per_term: -2.6952, per_day: +0.0329), # 穀雨(こくう)
64
+ rikka: Row.new(stack: +138.0, per_term: -2.1818, per_day: -0.0329), # 立夏(りっか)
65
+ shouman: Row.new(stack: +100.0, per_term: -2.6952, per_day: -0.0329), # 小満(しょうまん)
66
+ boushu: Row.new(stack: +54.0, per_term: -3.2086, per_day: -0.0329), # 芒種(ぼうしゅ)
67
+ geshi: Row.new(stack: 0.0, per_term: -3.7220, per_day: +0.0329), # 夏至(げし)
68
+ shousho: Row.new(stack: -54.0, per_term: -3.2086, per_day: +0.0329), # 小暑(しょうしょ)
69
+ taisho: Row.new(stack: -100.0, per_term: -2.6952, per_day: +0.0329), # 大暑(たいしょ)
70
+ risshuu: Row.new(stack: -138.0, per_term: -2.1818, per_day: -0.0329), # 立秋(りっしゅう)
71
+ shosho: Row.new(stack: -176.0, per_term: -2.6952, per_day: -0.0329), # 処暑(しょしょ)
72
+ hakuro: Row.new(stack: -222.0, per_term: -3.2086, per_day: -0.0329), # 白露(はくろ)
73
+ shuubun: Row.new(stack: -276.0, per_term: +3.9546, per_day: -0.0372), # 秋分(しゅうぶん)
74
+ kanro: Row.new(stack: -222.0, per_term: +3.4091, per_day: -0.0372), # 寒露(かんろ)
75
+ soukou: Row.new(stack: -176.0, per_term: +2.8636, per_day: -0.0372), # 霜降(そうこう)
76
+ rittou: Row.new(stack: -138.0, per_term: +2.3181, per_day: +0.0372), # 立冬(りっとう)
77
+ shousetsu: Row.new(stack: -100.0, per_term: +2.8636, per_day: +0.0372), # 小雪(しょうせつ)
78
+ taisetsu: Row.new(stack: -54.0, per_term: +3.4091, per_day: +0.0372) # 大雪(たいせつ)
79
+ }.freeze
78
80
 
79
- class << self
80
- #
81
- # 24気損益眺朒(ちょうじく)数の行データを特定する
82
- #
83
- # @param [Integer] index 連番(二十四節気)
84
- #
85
- # @return [Row] 行データ
86
- #
87
- def specify(index:)
88
- key = Cycle::SolarTerm::ORDER[index]
89
- Adjustment::MAP[key].clone
81
+ class << self
82
+ #
83
+ # 24気損益眺朒(ちょうじく)数の行データを特定する
84
+ #
85
+ # @param [Integer] index 連番(二十四節気)
86
+ #
87
+ # @return [Row] 行データ
88
+ #
89
+ def specify(index:)
90
+ key = Cycle::SolarTerm::ORDER[index]
91
+ Adjustment::MAP[key].clone
92
+ end
90
93
  end
91
94
  end
92
95
  end