zakuro 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -13
  3. data/VERSION +1 -1
  4. data/doc/dropped_date.md +93 -0
  5. data/doc/error.md +45 -0
  6. data/doc/operation/csv/month.csv +100 -79
  7. data/doc/operation/operation.xlsx +0 -0
  8. data/lib/zakuro/calculation/base/day.rb +52 -0
  9. data/lib/zakuro/calculation/base/gengou.rb +5 -5
  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/abstract_scroll.rb +38 -29
  17. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
  18. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
  19. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
  22. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
  23. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
  24. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
  25. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
  26. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
  27. data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
  28. data/lib/zakuro/calculation/era/version/version.rb +12 -10
  29. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
  30. data/lib/zakuro/calculation/monthly/const.rb +18 -0
  31. data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
  32. data/lib/zakuro/calculation/monthly/month.rb +17 -17
  33. data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
  34. data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
  35. data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
  36. data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
  37. data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
  38. data/lib/zakuro/calculation/range/abstract_full_range.rb +40 -25
  39. data/lib/zakuro/calculation/range/abstract_operation_range.rb +111 -109
  40. data/lib/zakuro/calculation/range/dated_full_range.rb +1 -1
  41. data/lib/zakuro/calculation/range/dated_operation_range.rb +1 -1
  42. data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
  43. data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
  44. data/lib/zakuro/calculation/range/named_operation_range.rb +1 -1
  45. data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
  46. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
  47. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
  48. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
  49. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
  50. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
  51. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
  52. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
  53. data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
  54. data/lib/zakuro/calculation/summary/internal/month.rb +32 -11
  55. data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
  56. data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
  57. data/lib/zakuro/calculation/summary/japan/range.rb +145 -118
  58. data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
  59. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +57 -50
  60. data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
  61. data/lib/zakuro/calculation/summary/western/range.rb +95 -92
  62. data/lib/zakuro/calculation/summary/western/single.rb +78 -76
  63. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -119
  64. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +63 -56
  65. data/lib/zakuro/calculation/type/old_float.rb +2 -2
  66. data/lib/zakuro/calculation/type/optional.rb +46 -0
  67. data/lib/zakuro/condition.rb +142 -92
  68. data/lib/zakuro/context/context.rb +44 -0
  69. data/lib/zakuro/context/option.rb +119 -0
  70. data/lib/zakuro/context/version_class_resolver.rb +112 -0
  71. data/lib/zakuro/era/japan/calendar.rb +35 -33
  72. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +8 -4
  73. data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
  74. data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
  75. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
  76. data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
  77. data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -34
  78. data/lib/zakuro/era/japan/gengou/resource/type.rb +45 -37
  79. data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
  80. data/lib/zakuro/era/japan/gengou.rb +28 -26
  81. data/lib/zakuro/era/japan/version.rb +18 -16
  82. data/lib/zakuro/era/western/calendar.rb +104 -88
  83. data/lib/zakuro/exception/case/pattern.rb +39 -3
  84. data/lib/zakuro/exception/case/preset.rb +2 -2
  85. data/lib/zakuro/exception/exception.rb +17 -15
  86. data/lib/zakuro/exception/zakuro_error.rb +19 -1
  87. data/lib/zakuro/gateway/locale/date.rb +2 -2
  88. data/lib/zakuro/gateway/locale/range.rb +3 -3
  89. data/lib/zakuro/gateway/range.rb +3 -3
  90. data/lib/zakuro/gateway/single.rb +14 -3
  91. data/lib/zakuro/merchant.rb +79 -9
  92. data/lib/zakuro/operation/month/parser.rb +252 -249
  93. data/lib/zakuro/operation/month/type.rb +17 -8
  94. data/lib/zakuro/operation/month/validator.rb +148 -144
  95. data/lib/zakuro/operation/operation.rb +38 -36
  96. data/lib/zakuro/operation/yaml/month.yaml +955 -281
  97. data/lib/zakuro/output/response.rb +107 -141
  98. data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
  99. data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
  100. data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
  101. data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
  102. data/lib/zakuro/result/data/single_day.rb +9 -1
  103. data/lib/zakuro/result/operation/month/annotation.rb +2 -2
  104. data/lib/zakuro/result/operation/month/history.rb +2 -2
  105. data/lib/zakuro/result/operation/month.rb +31 -0
  106. data/lib/zakuro/result/operation.rb +39 -0
  107. data/lib/zakuro/result/result.rb +3 -3
  108. data/lib/zakuro/tools/stringifier.rb +67 -42
  109. data/lib/zakuro/tools/typeconv.rb +17 -15
  110. data/lib/zakuro/tools/typeof.rb +15 -13
  111. data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
  112. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
  113. data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
  114. data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
  115. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
  116. data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
  117. data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
  118. data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
  119. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
  120. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
  121. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
  122. data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
  123. data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
  124. data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
  125. data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
  126. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
  127. data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
  128. data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
  129. data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
  130. data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
  131. data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
  132. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
  133. data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
  134. data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
  135. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
  136. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
  137. data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
  138. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
  139. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
  140. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
  141. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
  142. data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
  143. data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
  144. data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
  145. data/lib/zakuro/version/senmyou/const/remainder.rb +7 -1
  146. data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
  147. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
  148. data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
  149. data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
  150. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
  151. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
  152. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
  153. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
  154. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
  155. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
  156. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
  157. data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
  158. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
  159. data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
  160. metadata +27 -7
  161. data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
  162. data/lib/zakuro/result/operation/month/bundle.rb +0 -36
  163. data/lib/zakuro/result/operation/operation.rb +0 -44
  164. data/lib/zakuro/version/context.rb +0 -44
  165. 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
@@ -83,24 +83,26 @@ module Zakuro
83
83
  MAP[:taisetsu] # 23
84
84
  ].freeze
85
85
 
86
- #
87
- # 入気定日加減数を引き当てる
88
- #
89
- # @param [Integer] index 二十四節気番号
90
- #
91
- # @return [Cycle::Remainder] 入気定日加減数
92
- #
93
- def self.index_of(index)
94
- LIST[index]
95
- end
86
+ class << self
87
+ #
88
+ # 入気定日加減数を引き当てる
89
+ #
90
+ # @param [Integer] index 二十四節気番号
91
+ #
92
+ # @return [Cycle::Remainder] 入気定日加減数
93
+ #
94
+ def index_of(index)
95
+ LIST[index]
96
+ end
96
97
 
97
- #
98
- # 入気定日加減数の総数を返す
99
- #
100
- # @return [Integer] 入気定日加減数の総数
101
- #
102
- def self.size
103
- LIST.size
98
+ #
99
+ # 入気定日加減数の総数を返す
100
+ #
101
+ # @return [Integer] 入気定日加減数の総数
102
+ #
103
+ def size
104
+ LIST.size
105
+ end
104
106
  end
105
107
  end
106
108
  end
@@ -16,19 +16,21 @@ module Zakuro
16
16
  # Value 太陽補正値
17
17
  #
18
18
  module Value
19
- #
20
- # 太陽の運行による補正値を算出する
21
- #
22
- # @param [SolarTerm] solar_location 入定気
23
- #
24
- # @return [Integer] 補正値
25
- #
26
- def self.get(solar_location:)
27
- remainder = solar_location.remainder
19
+ class << self
20
+ #
21
+ # 太陽の運行による補正値を算出する
22
+ #
23
+ # @param [SolarTerm] solar_location 入定気
24
+ #
25
+ # @return [Integer] 補正値
26
+ #
27
+ def get(solar_location:)
28
+ remainder = solar_location.remainder
28
29
 
29
- row = Adjustment.specify(index: solar_location.index)
30
+ row = Adjustment.specify(index: solar_location.index)
30
31
 
31
- Calculation::Solar::ChoukeiValue.get(remainder: remainder, row: row)
32
+ Calculation::Solar::ChoukeiValue.get(remainder: remainder, row: row)
33
+ end
32
34
  end
33
35
  end
34
36
  end
@@ -25,6 +25,11 @@ module Zakuro
25
25
  #
26
26
  # @return [Cycle::Remainder] 弦(1分=8秒)
27
27
  QUARTER = Cycle::Remainder.new(day: 7, minute: 3214, second: 2)
28
+
29
+ # @return [Cycle::Remainder] 有没判定
30
+ # * 中盈(小余3671秒2)/ 2 = 小余1835秒5
31
+ # * 日(小余8400) - 小余1835秒5 = 小余6564秒3
32
+ DROPPED_DATE_LIMIT = Cycle::Remainder.new(day: 0, minute: 6564, second: 3)
28
33
  end
29
34
 
30
35
  #
@@ -39,7 +44,8 @@ module Zakuro
39
44
  # @note 章月 248057 = 29-4457
40
45
  #
41
46
  # @return [Cycle::LunarRemainder] 弦(1分=100秒)
42
- QUARTER = Cycle::LunarRemainder.new(day: 7, minute: 3214, second: 25)
47
+ # TODO: 秒が25では通らない。少なくとも0.00546は必要になる(最大 0.01863)
48
+ QUARTER = Cycle::LunarRemainder.new(day: 7, minute: 3214, second: 25.00546)
43
49
  end
44
50
  end
45
51
  end
@@ -26,7 +26,7 @@ module Zakuro
26
26
  # @param [Integer] total 繰り上げなしの小余
27
27
  #
28
28
  def initialize(day: -1, minute: -1, second: -1, total: -1)
29
- super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
29
+ super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
30
30
  day: day, minute: minute, second: second, total: total)
31
31
  end
32
32
 
@@ -60,7 +60,42 @@ module Zakuro
60
60
  # @param [Integer] total 繰り上げなしの小余
61
61
  #
62
62
  def initialize(day: -1, minute: -1, second: -1, total: -1)
63
- super(base_day: Const::Number::Cycle::DAY, base_mitune: MINUTE,
63
+ super(base_day: Const::Number::Cycle::DAY, base_minute: MINUTE,
64
+ day: day, minute: minute, second: second, total: total)
65
+ end
66
+
67
+ #
68
+ # 特定の文字フォーマットにして出力する
69
+ #
70
+ # @param [String] form フォーマット(大余、小余、秒それぞれを%dで指定する)
71
+ #
72
+ # @return [String] フォーマットした結果
73
+ #
74
+ def format(form: '%d-%d')
75
+ return '' if invalid?
76
+
77
+ super(form, @day, @minute, @second)
78
+ end
79
+ end
80
+
81
+ #
82
+ # DroppedRemainder 没日の計算向け時刻情報(没余)
83
+ #
84
+ class DroppedRemainder < Calculation::Cycle::AbstractRemainder
85
+ # @return [Integer] 分(1分=8秒)
86
+ MINUTE = 8
87
+
88
+ #
89
+ # 初期化
90
+ #
91
+ # @param [Integer] day 大余("日"に相当)
92
+ # @param [Integer] minute 小余("分"に相当)
93
+ # @param [Integer] second 秒
94
+ # @param [Integer] total 繰り上げなしの小余
95
+ #
96
+ def initialize(day: -1, minute: -1, second: -1, total: -1)
97
+ # 小余 = 通余
98
+ super(base_day: Const::Number::Derivation::REMAINDER_ALL_YEAR, base_minute: MINUTE,
64
99
  day: day, minute: minute, second: second, total: total)
65
100
  end
66
101
 
@@ -35,7 +35,7 @@ module Zakuro
35
35
  lunar_age = Origin::LunarAge.get(western_year: western_year)
36
36
 
37
37
  super(
38
- quater: QUARTER,
38
+ quarter: QUARTER,
39
39
  average_remainder: Origin::AverageNovember.get(western_year: western_year),
40
40
  solar_location: Solar::Location.new(lunar_age: lunar_age),
41
41
  lunar_location: Lunar::Location.new(
@@ -55,10 +55,10 @@ module Zakuro
55
55
  # @return [Remainder] 定朔
56
56
  #
57
57
  def current_remainder
58
- debug("@average_remainder.format: #{@average_remainder.format}")
58
+ debug("average_remainder.format: #{average_remainder.format}")
59
59
 
60
60
  sum = correction_value
61
- adjusted = @average_remainder.add(
61
+ adjusted = average_remainder.add(
62
62
  Cycle::Remainder.new(day: 0, minute: sum, second: 0)
63
63
  )
64
64
  adjusted.up_on_new_moon!
@@ -74,11 +74,11 @@ module Zakuro
74
74
  # @return [Integer] 太陽運動の補正値
75
75
  #
76
76
  def correction_solar_value
77
- @solar_location.run
78
- debug("@solar_term.remainder: #{@solar_location.remainder.format(form: '%d-%d.%d')}")
79
- debug("@solar_term.index: #{@solar_location.index}")
77
+ solar_location.run
78
+ debug("solar_term.remainder: #{solar_location.remainder.format(form: '%d-%d.%d')}")
79
+ debug("solar_term.index: #{solar_location.index}")
80
80
 
81
- Solar::Value.get(solar_location: @solar_location)
81
+ Solar::Value.get(solar_location: solar_location)
82
82
  end
83
83
 
84
84
  # :reek:TooManyStatements { max_statements: 6 }
@@ -89,10 +89,10 @@ module Zakuro
89
89
  # @return [Integer] 月運動の補正値
90
90
  #
91
91
  def correction_moon_value
92
- @lunar_location.run
92
+ lunar_location.run
93
93
 
94
- remainder = @lunar_location.adjusted_remainder
95
- forward = @lunar_location.forward
94
+ remainder = lunar_location.adjusted_remainder
95
+ forward = lunar_location.forward
96
96
 
97
97
  debug("[lunar]remainder.format: #{remainder.format}")
98
98
  debug("[lunar]forward: #{forward}")
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../../calculation/option/dropped_date/abstract_parameter'
4
+
5
+ require_relative '../../const/number'
6
+ require_relative '../../const/remainder'
7
+ require_relative '../../cycle/remainder'
8
+
9
+ # :nodoc:
10
+ module Zakuro
11
+ # :nodoc:
12
+ module Senmyou
13
+ # :nodoc:
14
+ module Option
15
+ # :nodoc:
16
+ module DroppedDate
17
+ #
18
+ # Parameter 引数
19
+ #
20
+ class Parameter < Calculation::Option::DroppedDate::AbstractParameter
21
+ #
22
+ # 初期化
23
+ #
24
+ def initialize
25
+ super(valid: true, year: Const::Number::Cycle::YEAR,
26
+ limit: Const::Remainder::Solar::DROPPED_DATE_LIMIT,
27
+ remainder_class: Cycle::DroppedRemainder)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -14,24 +14,26 @@ module Zakuro
14
14
  # AnnualRange 年間範囲
15
15
  #
16
16
  module AnnualRange
17
- #
18
- # 一覧取得する
19
- #
20
- # * 対象年に対して、前年11月-当年11月までを出力する
21
- # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
22
- #
23
- # @param [Context] context 暦コンテキスト
24
- # @param [Integer] western_year 西暦年
25
- #
26
- # @return [Array<Month>] 1年データ
27
- #
28
- def self.get(context:, western_year:)
29
- lunar_phase = Monthly::LunarPhase.new(western_year: western_year)
30
- solar_average = Solar::Average.new(western_year: western_year)
17
+ class << self
18
+ #
19
+ # 一覧取得する
20
+ #
21
+ # * 対象年に対して、前年11月-当年11月までを出力する
22
+ # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
23
+ #
24
+ # @param [Context::Context] context 暦コンテキスト
25
+ # @param [Integer] western_year 西暦年
26
+ #
27
+ # @return [Array<Month>] 1年データ
28
+ #
29
+ def get(context:, western_year:)
30
+ lunar_phase = Monthly::LunarPhase.new(western_year: western_year)
31
+ solar_average = Solar::Average.new(western_year: western_year)
31
32
 
32
- Calculation::Range::MedievalAnnualRange.get(
33
- context: context, lunar_phase: lunar_phase, solar_average: solar_average
34
- )
33
+ Calculation::Range::MedievalAnnualRange.get(
34
+ context: context, lunar_phase: lunar_phase, solar_average: solar_average
35
+ )
36
+ end
35
37
  end
36
38
  end
37
39
  end
@@ -57,11 +57,13 @@ module Zakuro
57
57
  # @return [False] 不一致
58
58
  #
59
59
  def match?(forward:, day:, minute:)
60
- return false unless @forward == forward
60
+ inner_forward = @forward
61
+ return false unless inner_forward == forward
61
62
 
62
- return false unless @day == day
63
+ inner_day = @day
64
+ return false unless inner_day == day
63
65
 
64
- return false unless @range.include?(minute: minute)
66
+ return false unless range.include?(minute: minute)
65
67
 
66
68
  true
67
69
  end
@@ -72,7 +74,7 @@ module Zakuro
72
74
  # @return [Integer] 分母
73
75
  #
74
76
  def denominator
75
- @range.denominator
77
+ range.denominator
76
78
  end
77
79
  end
78
80
 
@@ -114,7 +116,7 @@ module Zakuro
114
116
  # @return [False] 含まれない
115
117
  #
116
118
  def include?(minute:)
117
- minute >= @min && minute <= @max
119
+ minute >= min && minute <= max
118
120
  end
119
121
 
120
122
  #
@@ -123,7 +125,7 @@ module Zakuro
123
125
  # @return [Integer] 分母
124
126
  #
125
127
  def denominator
126
- @max - @min
128
+ max - min
127
129
  end
128
130
  end
129
131
 
@@ -153,7 +155,7 @@ module Zakuro
153
155
  # @return [String] 文字
154
156
  #
155
157
  def to_s
156
- "per:#{@per}, stack:#{@stack}"
158
+ "per:#{per}, stack:#{stack}"
157
159
  end
158
160
  end
159
161
 
@@ -196,40 +198,44 @@ module Zakuro
196
198
  ].freeze
197
199
  # rubocop:enable Layout/LineLength
198
200
 
199
- #
200
- # 月軌道の補正に必要な基本値を引き当てる
201
- #
202
- # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
203
- # @param [Integer] day 大余
204
- # @param [Integer] minute 小余
205
- #
206
- # @return [Row] 補正値
207
- #
208
- def self.specify(forward:, day:, minute:)
209
- LIST.each do |row|
210
- # NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
211
- return row if row.match?(forward: forward, day: day, minute: minute)
212
- end
201
+ class << self
202
+ #
203
+ # 月軌道の補正に必要な基本値を引き当てる
204
+ #
205
+ # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
206
+ # @param [Integer] day 大余
207
+ # @param [Integer] minute 小余
208
+ #
209
+ # @return [Row] 補正値
210
+ #
211
+ # @raise [ArgumentError] 引数エラー
212
+ #
213
+ def specify(forward:, day:, minute:)
214
+ LIST.each do |row|
215
+ # NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
216
+ return row if row.match?(forward: forward, day: day, minute: minute)
217
+ end
213
218
 
214
- raise ArgumentError.new, "invalid parameter: #{forward}/#{day}/#{minute}"
215
- end
219
+ raise ArgumentError.new, "invalid parameter: #{forward}/#{day}/#{minute}"
220
+ end
216
221
 
217
- # :reek:ControlParameter
222
+ # :reek:ControlParameter
218
223
 
219
- #
220
- # 小余の下げ幅を求める
221
- #
222
- # @param [Integer] day 大余
223
- # @param [Integer] minute 小余
224
- #
225
- # @return [Integer] 小余の下げ幅
226
- #
227
- def self.minus_minute(day:, minute:)
228
- return minute unless HALF_DAYS.include?(day)
224
+ #
225
+ # 小余の下げ幅を求める
226
+ #
227
+ # @param [Integer] day 大余
228
+ # @param [Integer] minute 小余
229
+ #
230
+ # @return [Integer] 小余の下げ幅
231
+ #
232
+ def minus_minute(day:, minute:)
233
+ return minute unless HALF_DAYS.include?(day)
229
234
 
230
- return minute unless minute > Range::HALF
235
+ return minute unless minute > Range::HALF
231
236
 
232
- minute - Range::HALF
237
+ minute - Range::HALF
238
+ end
233
239
  end
234
240
  end
235
241
  end
@@ -21,22 +21,24 @@ module Zakuro
21
21
  # @return [Integer] 年
22
22
  YEAR = Const::Number::Cycle::YEAR
23
23
 
24
- #
25
- # 対象年の最初の入暦を求める
26
- #
27
- # @param [Remainder] lunar_age 天正閏余
28
- # @param [Integer] western_year 西暦年
29
- #
30
- # @return [Cycle::LunarRemainder] 入暦
31
- #
32
- def self.first_remainder(lunar_age:, western_year:)
33
- # 積年の開始から対象年までの年数
34
- total_year = TOTAL_YEAR + western_year - BEGIN_YEAR
24
+ class << self
25
+ #
26
+ # 対象年の最初の入暦を求める
27
+ #
28
+ # @param [Remainder] lunar_age 天正閏余
29
+ # @param [Integer] western_year 西暦年
30
+ #
31
+ # @return [Cycle::LunarRemainder] 入暦
32
+ #
33
+ def first_remainder(lunar_age:, western_year:)
34
+ # 積年の開始から対象年までの年数
35
+ total_year = TOTAL_YEAR + western_year - BEGIN_YEAR
35
36
 
36
- # 通積分 - 天正閏余
37
- total_day = total_year * YEAR - lunar_age.to_minute
37
+ # 通積分 - 天正閏余
38
+ total_day = total_year * YEAR - lunar_age.to_minute
38
39
 
39
- Cycle::LunarRemainder.new(total: (total_day % ANOMALISTIC_MONTH))
40
+ Cycle::LunarRemainder.new(total: (total_day % ANOMALISTIC_MONTH))
41
+ end
40
42
  end
41
43
  end
42
44
  end
@@ -18,49 +18,54 @@ module Zakuro
18
18
  module Value
19
19
  # :reek:TooManyStatements { max_statements: 9 }
20
20
 
21
- #
22
- # 月の運行による補正値を算出する
23
- #
24
- # @param [Cycle::LunarRemainder] remainder 月の大余小余
25
- # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
26
- #
27
- # @return [Integer] 補正値
28
- #
29
- def self.get(remainder:, forward:)
30
- valid?(remainder: remainder)
21
+ class << self
22
+ #
23
+ # 月の運行による補正値を算出する
24
+ #
25
+ # @param [Cycle::LunarRemainder] remainder 月の大余小余
26
+ # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
27
+ #
28
+ # @return [Integer] 補正値
29
+ #
30
+ def get(remainder:, forward:)
31
+ valid?(remainder: remainder)
31
32
 
32
- day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
33
- remainder: remainder
34
- )
33
+ day, minute = Calculation::Lunar::ChoukeiValue.remainder_without_second(
34
+ remainder: remainder
35
+ )
35
36
 
36
- # 引き当て
37
- row = Adjustment.specify(forward: forward, day: day, minute: minute)
37
+ # 引き当て
38
+ row = Adjustment.specify(forward: forward, day: day, minute: minute)
38
39
 
39
- value = row.value
40
+ value = row.value
40
41
 
41
- minus_minute = Adjustment.minus_minute(day: day, minute: minute)
42
+ minus_minute = Adjustment.minus_minute(day: day, minute: minute)
42
43
 
43
- day = Calculation::Lunar::ChoukeiValue.rounded_day(
44
- per: value.per, denominator: row.denominator, minute: minus_minute
45
- )
44
+ day = Calculation::Lunar::ChoukeiValue.rounded_day(
45
+ per: value.per, denominator: row.denominator, minute: minus_minute
46
+ )
46
47
 
47
- value.stack + day
48
- end
48
+ value.stack + day
49
+ end
50
+
51
+ private
49
52
 
50
- #
51
- # 大余小余を検証する
52
- #
53
- # @param [Cycle::LunarRemainder] remainder 大余小余
54
- #
55
- # @return [True] 正しい(月の位相計算に使う大余小余)
56
- # @return [True] 正しくない
57
- #
58
- def self.valid?(remainder:)
59
- return if remainder.is_a?(Cycle::LunarRemainder)
53
+ #
54
+ # 大余小余を検証する
55
+ #
56
+ # @param [Cycle::LunarRemainder] remainder 大余小余
57
+ #
58
+ # @return [True] 正しい(月の位相計算に使う大余小余)
59
+ # @return [True] 正しくない
60
+ #
61
+ # @raise [ArgumentError] 引数エラー
62
+ #
63
+ def valid?(remainder:)
64
+ return if remainder.is_a?(Cycle::LunarRemainder)
60
65
 
61
- raise ArgumentError, "unmatch parameter type: #{remainder.class}"
66
+ raise ArgumentError, "unmatch parameter type: #{remainder.class}"
67
+ end
62
68
  end
63
- private_class_method :valid?
64
69
  end
65
70
  end
66
71
  end