zakuro 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/VERSION +1 -1
  4. data/lib/zakuro/calculation/base/gengou.rb +5 -5
  5. data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
  6. data/lib/zakuro/calculation/base/operated_year.rb +23 -21
  7. data/lib/zakuro/calculation/base/year.rb +3 -3
  8. data/lib/zakuro/calculation/cycle/abstract_remainder.rb +50 -44
  9. data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
  10. data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
  11. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +38 -29
  12. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
  13. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
  14. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
  15. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
  16. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
  17. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
  18. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
  19. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
  22. data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
  23. data/lib/zakuro/calculation/era/version/version.rb +12 -10
  24. data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
  25. data/lib/zakuro/calculation/monthly/const.rb +18 -0
  26. data/lib/zakuro/calculation/monthly/initialized_month.rb +39 -37
  27. data/lib/zakuro/calculation/monthly/month.rb +15 -15
  28. data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
  29. data/lib/zakuro/calculation/monthly/operated_month.rb +36 -85
  30. data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
  31. data/lib/zakuro/calculation/range/abstract_full_range.rb +34 -21
  32. data/lib/zakuro/calculation/range/abstract_operation_range.rb +109 -107
  33. data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
  34. data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
  35. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
  36. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
  37. data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
  38. data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
  39. data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
  40. data/lib/zakuro/calculation/stella/solar/abstract_location.rb +5 -5
  41. data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
  42. data/lib/zakuro/calculation/summary/internal/day.rb +21 -19
  43. data/lib/zakuro/calculation/summary/internal/month.rb +25 -12
  44. data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
  45. data/lib/zakuro/calculation/summary/internal/option.rb +66 -50
  46. data/lib/zakuro/calculation/summary/japan/range.rb +145 -124
  47. data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
  48. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +54 -52
  49. data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
  50. data/lib/zakuro/calculation/summary/western/range.rb +95 -92
  51. data/lib/zakuro/calculation/summary/western/single.rb +78 -76
  52. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -124
  53. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +60 -58
  54. data/lib/zakuro/calculation/type/old_float.rb +2 -2
  55. data/lib/zakuro/condition.rb +121 -111
  56. data/lib/zakuro/context/context.rb +1 -1
  57. data/lib/zakuro/context/option.rb +31 -29
  58. data/lib/zakuro/context/version_class_resolver.rb +26 -24
  59. data/lib/zakuro/era/japan/calendar.rb +35 -33
  60. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +4 -4
  61. data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
  62. data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
  63. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
  64. data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
  65. data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -36
  66. data/lib/zakuro/era/japan/gengou/resource/type.rb +39 -37
  67. data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
  68. data/lib/zakuro/era/japan/gengou.rb +28 -26
  69. data/lib/zakuro/era/japan/version.rb +18 -16
  70. data/lib/zakuro/era/western/calendar.rb +102 -90
  71. data/lib/zakuro/exception/case/preset.rb +2 -2
  72. data/lib/zakuro/exception/exception.rb +15 -13
  73. data/lib/zakuro/exception/zakuro_error.rb +1 -1
  74. data/lib/zakuro/gateway/locale/date.rb +2 -2
  75. data/lib/zakuro/gateway/locale/range.rb +3 -3
  76. data/lib/zakuro/gateway/range.rb +1 -1
  77. data/lib/zakuro/gateway/single.rb +13 -2
  78. data/lib/zakuro/merchant.rb +1 -1
  79. data/lib/zakuro/operation/month/parser.rb +252 -251
  80. data/lib/zakuro/operation/month/type.rb +17 -8
  81. data/lib/zakuro/operation/month/validator.rb +148 -144
  82. data/lib/zakuro/operation/operation.rb +38 -36
  83. data/lib/zakuro/output/response.rb +112 -113
  84. data/lib/zakuro/result/operation/month/annotation.rb +2 -2
  85. data/lib/zakuro/result/operation/month/history.rb +2 -2
  86. data/lib/zakuro/result/operation/month.rb +31 -0
  87. data/lib/zakuro/result/operation.rb +39 -0
  88. data/lib/zakuro/result/result.rb +3 -3
  89. data/lib/zakuro/tools/stringifier.rb +66 -64
  90. data/lib/zakuro/tools/typeconv.rb +17 -15
  91. data/lib/zakuro/tools/typeof.rb +15 -13
  92. data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
  93. data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
  94. data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -39
  95. data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
  96. data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -49
  97. data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
  98. data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
  99. data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
  100. data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
  101. data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
  102. data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
  103. data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
  104. data/lib/zakuro/version/genka/cycle/remainder.rb +2 -2
  105. data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
  106. data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
  107. data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
  108. data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
  109. data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
  110. data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
  111. data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -39
  112. data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
  113. data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -49
  114. data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
  115. data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
  116. data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
  117. data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
  118. data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
  119. data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
  120. data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
  121. data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
  122. data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
  123. data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -38
  124. data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
  125. data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -36
  126. data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
  127. data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
  128. data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
  129. data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
  130. data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
  131. data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
  132. data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
  133. metadata +12 -9
  134. data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
  135. data/lib/zakuro/result/operation/bundle.rb +0 -44
  136. data/lib/zakuro/result/operation/month/bundle.rb +0 -36
@@ -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
@@ -42,7 +42,7 @@ module Zakuro
42
42
  def format(form: '%.4f', digit: 4)
43
43
  return '' if invalid?
44
44
 
45
- decimal = @day + @minute / @base_day.to_f
45
+ decimal = day + minute / base_day.to_f
46
46
  super(form, decimal.round(digit))
47
47
  end
48
48
  end
@@ -79,7 +79,7 @@ module Zakuro
79
79
  def format(form: '%.4f', digit: 4)
80
80
  return '' if invalid?
81
81
 
82
- decimal = @day + @minute / @base_day.to_f
82
+ decimal = day + minute / base_day.to_f
83
83
  # NOTE: roundなしで format を使用した場合は、四捨五入が正しく実行されないことが判明した
84
84
  # 具体的には、468年の中気は '55.7813' だが '55.7812' になる
85
85
  # これは '55.7812500' を4桁にした際に、境界値の少数点以下5桁目の '5' が切り捨てを受けたためである
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../../../calculation/monthly/const'
4
+
3
5
  require_relative '../const/remainder'
4
6
 
5
7
  require_relative '../cycle/solar_term'
@@ -21,11 +23,11 @@ module Zakuro
21
23
  # @return [Cycle::Remainder] 弦
22
24
  QUARTER = Const::Remainder::QUARTER
23
25
 
24
- # TODO: AbstractLunarPhase でも使用している
25
-
26
26
  # @return [Array<String>] 月内の弦
27
- PHASE_INDEXES = %w[朔日 上弦 望月 下弦].freeze
27
+ PHASE_INDEXES = Calculation::Monthly::Const::PHASE_INDEXES
28
28
 
29
+ # @return [Integer] 弦の位置
30
+ attr_reader :index
29
31
  # @return [Cycle::AbstractRemainder] 経
30
32
  attr_reader :remainder
31
33
 
@@ -80,12 +82,12 @@ module Zakuro
80
82
  #
81
83
  def next_index
82
84
  @index += 1
83
- @index = 0 if @index >= PHASE_INDEXES.size
85
+ @index = 0 if index >= PHASE_INDEXES.size
84
86
  @index
85
87
  end
86
88
 
87
89
  def add_quarter_moon_size
88
- @remainder.add!(QUARTER)
90
+ remainder.add!(QUARTER)
89
91
 
90
92
  next_index
91
93
  end
@@ -18,58 +18,62 @@ module Zakuro
18
18
  # @return [Output::Logger] ロガー
19
19
  LOGGER = Output::Logger.new(location: 'annual_range')
20
20
 
21
- #
22
- # 一覧取得する
23
- #
24
- # * 対象年に対して、当年1月-翌年1月までを出力する
25
- # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
26
- #
27
- # @param [Context::Context] context 暦コンテキスト
28
- # @param [Integer] western_year 西暦年
29
- #
30
- # @return [Array<Month>] 1年データ
31
- #
32
- def self.get(context:, western_year:)
33
- # 正月中気
34
- solar_term = Cycle::SolarTerm.new(
35
- index: 4, remainder: Origin::FirstTerm.get(western_year: western_year)
36
- )
37
- # 正月に立春が含まれる可能性があるので、立春まで戻しておく
38
- solar_term.prev_term!
21
+ class << self
22
+ #
23
+ # 一覧取得する
24
+ #
25
+ # * 対象年に対して、当年1月-翌年1月までを出力する
26
+ # * 対象年(西暦)と計算年(元号x年)の紐付けは行わない
27
+ #
28
+ # @param [Context::Context] context 暦コンテキスト
29
+ # @param [Integer] western_year 西暦年
30
+ #
31
+ # @return [Array<Month>] 1年データ
32
+ #
33
+ def get(context:, western_year:)
34
+ # 正月中気
35
+ solar_term = Cycle::SolarTerm.new(
36
+ index: 4, remainder: Origin::FirstTerm.get(western_year: western_year)
37
+ )
38
+ # 正月に立春が含まれる可能性があるので、立春まで戻しておく
39
+ solar_term.prev_term!
39
40
 
40
- # 経
41
- remainder = Origin::January.get(western_year: western_year)
41
+ # 経
42
+ remainder = Origin::January.get(western_year: western_year)
42
43
 
43
- lunar_phase = Monthly::LunarPhase.new(remainder: remainder)
44
+ lunar_phase = Monthly::LunarPhase.new(remainder: remainder)
44
45
 
45
- solar_average = Solar::Average.new(solar_term: solar_term)
46
+ solar_average = Solar::Average.new(solar_term: solar_term)
46
47
 
47
- annual_range = Calculation::Range::MedievalAnnualRange.get(
48
- context: context, lunar_phase: lunar_phase, solar_average: solar_average
49
- )
48
+ annual_range = Calculation::Range::MedievalAnnualRange.get(
49
+ context: context, lunar_phase: lunar_phase, solar_average: solar_average
50
+ )
50
51
 
51
- pop_months_on_next_year(annual_range: annual_range)
52
- end
52
+ pop_months_on_next_year(annual_range: annual_range)
53
+ end
53
54
 
54
- #
55
- # 来年の月を除去する
56
- #
57
- # @param [Array<Month>] annual_range 1年データ
58
- #
59
- # @return [Array<Month>] 1年データ
60
- #
61
- def self.pop_months_on_next_year(annual_range:)
62
- result = []
63
- number = 0
64
- annual_range.each do |month|
65
- # 来年
66
- break if number > month.month_label.number
55
+ private
67
56
 
68
- number = month.month_label.number
69
- result.push(month)
70
- end
57
+ #
58
+ # 来年の月を除去する
59
+ #
60
+ # @param [Array<Month>] annual_range 1年データ
61
+ #
62
+ # @return [Array<Month>] 1年データ
63
+ #
64
+ def pop_months_on_next_year(annual_range:)
65
+ result = []
66
+ number = 0
67
+ annual_range.each do |month|
68
+ # 来年
69
+ break if number > month.month_label.number
71
70
 
72
- result
71
+ number = month.month_label.number
72
+ result.push(month)
73
+ end
74
+
75
+ result
76
+ end
73
77
  end
74
78
  end
75
79
  end
@@ -20,34 +20,36 @@ module Zakuro
20
20
  # @return [Integer] 西暦0年の積年
21
21
  WESTERN_YEAR = Const::Number::Stack::WESTERN_YEAR
22
22
 
23
- #
24
- # 年初の中気(正月中雨水)を求める
25
- #
26
- # @note 計算は宋書(1)に従う。念のため『日本暦日原典』(2)と比較する
27
- # 1. (1612 + 西暦年) * 餘数(1595) / 度法(304) = A' ...余りが中気の小余
28
- # A' / 60 = B' ...余りが朔の大余
29
- # 『歴代天文律暦等志彙編 六』中華書房 p.1728
30
- #
31
- # 2. (1612 + x) * 222070 / 608 = A' ...余りが中気の小余
32
- # A' / 60 = B' ...余りが朔の大余
33
- #
34
- # 小余上限(度法)の違いで、宋書に従ったほうが良いと判断した。分母が変わるだけで結果に相違はない
35
- #
36
- # @param [Integer] western_year 西暦年
37
- #
38
- # @return [Remainder] 年初の中気(正月中雨水)
39
- #
40
- def self.get(western_year:)
41
- total_western_year = WESTERN_YEAR + western_year
42
- # (1612 + x) * 222070 / 608 = A' ...余りが中気の小余
43
- stack = (total_western_year * YEAR_REMAINDER / TERM_DAY).to_i
44
- minute = (total_western_year * YEAR_REMAINDER % TERM_DAY).to_i
45
- # A' / 60 = B' ...余りが朔の大余
46
- day = stack % Cycle::TermRemainder::LIMIT
47
- # p stack
48
- # p minute
49
- # p day
50
- Cycle::TermRemainder.new(day: day, minute: minute, second: 0)
23
+ class << self
24
+ #
25
+ # 年初の中気(正月中雨水)を求める
26
+ #
27
+ # @note 計算は宋書(1)に従う。念のため『日本暦日原典』(2)と比較する
28
+ # 1. (1612 + 西暦年) * 餘数(1595) / 度法(304) = A' ...余りが中気の小余
29
+ # A' / 60 = B' ...余りが朔の大余
30
+ # 『歴代天文律暦等志彙編 六』中華書房 p.1728
31
+ #
32
+ # 2. (1612 + x) * 222070 / 608 = A' ...余りが中気の小余
33
+ # A' / 60 = B' ...余りが朔の大余
34
+ #
35
+ # 小余上限(度法)の違いで、宋書に従ったほうが良いと判断した。分母が変わるだけで結果に相違はない
36
+ #
37
+ # @param [Integer] western_year 西暦年
38
+ #
39
+ # @return [Remainder] 年初の中気(正月中雨水)
40
+ #
41
+ def get(western_year:)
42
+ total_western_year = WESTERN_YEAR + western_year
43
+ # (1612 + x) * 222070 / 608 = A' ...余りが中気の小余
44
+ stack = (total_western_year * YEAR_REMAINDER / TERM_DAY).to_i
45
+ minute = (total_western_year * YEAR_REMAINDER % TERM_DAY).to_i
46
+ # A' / 60 = B' ...余りが朔の大余
47
+ day = stack % Cycle::TermRemainder::LIMIT
48
+ # p stack
49
+ # p minute
50
+ # p day
51
+ Cycle::TermRemainder.new(day: day, minute: minute, second: 0)
52
+ end
51
53
  end
52
54
  end
53
55
  end
@@ -22,26 +22,28 @@ module Zakuro
22
22
  # @return [Float] 19年=235朔望月
23
23
  METONIC_CYCLE = 235 / 19.to_f
24
24
 
25
- #
26
- # 1月経朔を求める
27
- #
28
- # @param [Integer] western_year 西暦年
29
- #
30
- # @return [Remainder] 11月経朔
31
- #
32
- def self.get(western_year:)
33
- # (1612 + x) * 235 / 19 = A ...余り
34
- stack = ((WESTERN_YEAR + western_year) * METONIC_CYCLE).to_i
35
- # A * 22207 / 752 = B ...余りが朔の小余
36
- minute_total = (stack * SYNODIC_MONTH / DAY).to_i
37
- minute = (stack * SYNODIC_MONTH % DAY).to_i
38
- # B / 60 = C ...余りが朔の大余
39
- day = minute_total % Cycle::Remainder::LIMIT
40
- # p stack
41
- # p minute_total
42
- # p minute
43
- # p day
44
- Cycle::Remainder.new(day: day, minute: minute, second: 0)
25
+ class << self
26
+ #
27
+ # 1月経朔を求める
28
+ #
29
+ # @param [Integer] western_year 西暦年
30
+ #
31
+ # @return [Remainder] 11月経朔
32
+ #
33
+ def get(western_year:)
34
+ # (1612 + x) * 235 / 19 = A ...余り
35
+ stack = ((WESTERN_YEAR + western_year) * METONIC_CYCLE).to_i
36
+ # A * 22207 / 752 = B ...余りが朔の小余
37
+ minute_total = (stack * SYNODIC_MONTH / DAY).to_i
38
+ minute = (stack * SYNODIC_MONTH % DAY).to_i
39
+ # B / 60 = C ...余りが朔の大余
40
+ day = minute_total % Cycle::Remainder::LIMIT
41
+ # p stack
42
+ # p minute_total
43
+ # p minute
44
+ # p day
45
+ Cycle::Remainder.new(day: day, minute: minute, second: 0)
46
+ end
45
47
  end
46
48
  end
47
49
  end
@@ -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(form: '%d-%d-%.5f')}")
58
+ # debug("average_remainder.format: #{average_remainder.format(form: '%d-%d-%.5f')}")
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
  # NOTE: 儀鳳暦では進朔しない
@@ -75,11 +75,11 @@ module Zakuro
75
75
  # @return [Integer] 太陽運動の補正値
76
76
  #
77
77
  def correction_solar_value
78
- @solar_location.run
79
- # debug("@solar_term.remainder: #{@solar_location.remainder.format(form: '%d-%d-%.5f')}")
80
- # debug("@solar_term.index: #{@solar_location.index}")
78
+ solar_location.run
79
+ # debug("solar_term.remainder: #{solar_location.remainder.format(form: '%d-%d-%.5f')}")
80
+ # debug("solar_term.index: #{solar_location.index}")
81
81
 
82
- Solar::Value.get(solar_location: @solar_location)
82
+ Solar::Value.get(solar_location: solar_location)
83
83
  end
84
84
 
85
85
  # :reek:TooManyStatements { max_statements: 6 }
@@ -90,9 +90,9 @@ module Zakuro
90
90
  # @return [Integer] 月運動の補正値
91
91
  #
92
92
  def correction_moon_value
93
- @lunar_location.run
93
+ lunar_location.run
94
94
 
95
- remainder = @lunar_location.adjusted_remainder
95
+ remainder = lunar_location.adjusted_remainder
96
96
 
97
97
  # debug("[lunar]remainder.format: #{remainder.format(form: '%d-%d-%.5f')}")
98
98
  # debug("[lunar]remainder.day: #{remainder.day}")
@@ -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] 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
@@ -72,9 +72,10 @@ module Zakuro
72
72
  # @return [False] 不一致
73
73
  #
74
74
  def match?(day:, minute:)
75
- return false unless @day == day
75
+ inner_day = @day
76
+ return false unless inner_day == day
76
77
 
77
- return false unless @range.include?(minute: minute)
78
+ return false unless range.include?(minute: minute)
78
79
 
79
80
  true
80
81
  end
@@ -85,7 +86,7 @@ module Zakuro
85
86
  # @return [Integer] 分母
86
87
  #
87
88
  def denominator
88
- @range.denominator
89
+ range.denominator
89
90
  end
90
91
  end
91
92
 
@@ -123,7 +124,7 @@ module Zakuro
123
124
  # @return [False] 含まれない
124
125
  #
125
126
  def include?(minute:)
126
- minute >= @min && minute <= @max
127
+ minute >= min && minute <= max
127
128
  end
128
129
 
129
130
  #
@@ -132,7 +133,7 @@ module Zakuro
132
133
  # @return [Integer] 分母
133
134
  #
134
135
  def denominator
135
- @max - @min
136
+ max - min
136
137
  end
137
138
  end
138
139
 
@@ -162,7 +163,7 @@ module Zakuro
162
163
  # @return [String] 文字
163
164
  #
164
165
  def to_s
165
- "per:#{@per}, stack:#{@stack}"
166
+ "per:#{per}, stack:#{stack}"
166
167
  end
167
168
  end
168
169
 
@@ -207,44 +208,46 @@ module Zakuro
207
208
  ].freeze
208
209
  # rubocop:enable Layout/LineLength
209
210
 
210
- #
211
- # 月軌道の補正に必要な基本値を引き当てる
212
- #
213
- # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
214
- # @param [Integer] day 大余
215
- # @param [Integer] minute 小余
216
- #
217
- # @return [Row] 補正値
218
- #
219
- # @raise [ArgumentError] 引数エラー
220
- #
221
- def self.specify(day:, minute:)
222
- LIST.each do |row|
223
- # NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
224
- return row if row.match?(day: day, minute: minute)
225
- end
211
+ class << self
212
+ #
213
+ # 月軌道の補正に必要な基本値を引き当てる
214
+ #
215
+ # @param [True, False] forward 進(遠地点より数える)/退(近地点より数える)
216
+ # @param [Integer] day 大余
217
+ # @param [Integer] minute 小余
218
+ #
219
+ # @return [Row] 補正値
220
+ #
221
+ # @raise [ArgumentError] 引数エラー
222
+ #
223
+ def specify(day:, minute:)
224
+ LIST.each do |row|
225
+ # NOTE: 範囲が重複している場合、最初に引き当てたほうを優先する
226
+ return row if row.match?(day: day, minute: minute)
227
+ end
226
228
 
227
- raise ArgumentError.new, "invalid parameter: #{day}/#{minute}"
228
- end
229
+ raise ArgumentError.new, "invalid parameter: #{day}/#{minute}"
230
+ end
229
231
 
230
- # :reek:ControlParameter
232
+ # :reek:ControlParameter
231
233
 
232
- #
233
- # 小余の下げ幅を求める
234
- #
235
- # @param [Integer] day 大余
236
- # @param [Integer] minute 小余
237
- #
238
- # @return [Integer] 小余の下げ幅
239
- #
240
- def self.minus_minute(day:, minute:)
241
- limit = DAY_LIMIT.fetch(day, -1)
242
- # 該当なし
243
- return minute if limit == -1
234
+ #
235
+ # 小余の下げ幅を求める
236
+ #
237
+ # @param [Integer] day 大余
238
+ # @param [Integer] minute 小余
239
+ #
240
+ # @return [Integer] 小余の下げ幅
241
+ #
242
+ def minus_minute(day:, minute:)
243
+ limit = DAY_LIMIT.fetch(day, -1)
244
+ # 該当なし
245
+ return minute if limit == -1
244
246
 
245
- return minute unless minute > limit
247
+ return minute unless minute > limit
246
248
 
247
- minute - limit
249
+ minute - limit
250
+ end
248
251
  end
249
252
  end
250
253
  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