zakuro 0.0.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +102 -42
- data/doc/operation.md +25 -0
- data/doc/operation/csv/month.csv +202 -0
- data/doc/operation/operation.xlsx +0 -0
- data/doc/operation/transfer.rb +77 -0
- data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
- data/lib/zakuro/calculation/base/year.rb +107 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +459 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
- data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
- data/lib/zakuro/calculation/monthly/month.rb +187 -0
- data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
- data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
- data/lib/zakuro/calculation/range/full_range.rb +210 -0
- data/lib/zakuro/calculation/range/operated_range.rb +144 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
- data/lib/zakuro/calculation/summary/single.rb +129 -0
- data/lib/zakuro/condition.rb +16 -13
- data/lib/zakuro/era/japan/gengou.rb +106 -0
- data/lib/zakuro/era/japan/gengou/parser.rb +167 -0
- data/lib/zakuro/era/japan/gengou/type.rb +178 -0
- data/lib/zakuro/era/japan/gengou/validator.rb +236 -0
- data/lib/zakuro/era/japan/reki.rb +91 -0
- data/lib/zakuro/era/{gengou → japan/yaml}/set-001-until-south.yaml +0 -0
- data/lib/zakuro/era/{gengou → japan/yaml}/set-002-from-north.yaml +0 -0
- data/lib/zakuro/era/{gengou → japan/yaml}/set-003-modern.yaml +0 -0
- data/lib/zakuro/era/western.rb +1 -1
- data/lib/zakuro/merchant.rb +2 -2
- data/lib/zakuro/operation/month/parser.rb +373 -0
- data/lib/zakuro/operation/month/type.rb +453 -0
- data/lib/zakuro/operation/month/validator.rb +802 -0
- data/lib/zakuro/operation/operation.rb +66 -0
- data/lib/zakuro/operation/yaml/month.yaml +6452 -0
- data/lib/zakuro/output/error.rb +7 -4
- data/lib/zakuro/output/logger.rb +50 -47
- data/lib/zakuro/output/response.rb +146 -143
- data/lib/zakuro/result/core.rb +52 -0
- data/lib/zakuro/result/data.rb +187 -0
- data/lib/zakuro/result/operation.rb +114 -0
- data/lib/zakuro/result/result.rb +37 -0
- data/lib/zakuro/{output → tools}/stringifier.rb +16 -9
- data/lib/zakuro/tools/typeof.rb +33 -0
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/abstract_version.rb +1 -1
- data/lib/zakuro/version/context.rb +23 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +63 -0
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +31 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +186 -182
- data/lib/zakuro/version/senmyou/range/annual_range.rb +167 -0
- data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +6 -6
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +103 -152
- data/lib/zakuro/version/senmyou/stella/solar_location.rb +213 -0
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +3 -184
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +4 -4
- data/lib/zakuro/version/version_class_resolver.rb +62 -0
- data/lib/zakuro/version_factory.rb +3 -3
- metadata +53 -24
- data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
- data/lib/zakuro/cycle/zodiac.rb +0 -103
- data/lib/zakuro/era/japan.rb +0 -664
- data/lib/zakuro/output/result.rb +0 -225
- data/lib/zakuro/version/senmyou/base/era.rb +0 -83
- data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
- data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -205
- data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
- data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -66
- data/lib/zakuro/version/senmyou/base/year.rb +0 -104
- data/lib/zakuro/version/senmyou/monthly/month.rb +0 -122
- data/lib/zakuro/version/senmyou/summary/annual_range.rb +0 -187
- data/lib/zakuro/version/senmyou/summary/full_range.rb +0 -224
- data/lib/zakuro/version/senmyou/summary/specifier.rb +0 -100
| @@ -0,0 +1,213 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # :nodoc:
         | 
| 4 | 
            +
            module Zakuro
         | 
| 5 | 
            +
              # :nodoc:
         | 
| 6 | 
            +
              module Senmyou
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                # SolarLocation 入定気演算
         | 
| 9 | 
            +
                #
         | 
| 10 | 
            +
                # 入定気とは、太陽がどの二十四節気に属するか、またその二十四節気の開始点からどれだけ離れているかを示す
         | 
| 11 | 
            +
                #
         | 
| 12 | 
            +
                module SolarLocation
         | 
| 13 | 
            +
                  #
         | 
| 14 | 
            +
                  # Interval 入気定日加減数(二十四節気の間隔)
         | 
| 15 | 
            +
                  #
         | 
| 16 | 
            +
                  module Interval
         | 
| 17 | 
            +
                    # @return [Hash<Symbol, Remainder>] 一覧
         | 
| 18 | 
            +
                    LIST = {
         | 
| 19 | 
            +
                      # 冬至(とうじ)・大雪(たいせつ)
         | 
| 20 | 
            +
                      touji: Cycle::Remainder.new(day: 14, minute: 4235, second: 5),
         | 
| 21 | 
            +
                      taisetsu: Cycle::Remainder.new(day: 14, minute: 4235, second: 5),
         | 
| 22 | 
            +
                      # 小寒(しょうかん)・小雪(しょうせつ)
         | 
| 23 | 
            +
                      shoukan: Cycle::Remainder.new(day: 14, minute: 5235, second: 5),
         | 
| 24 | 
            +
                      shousetsu: Cycle::Remainder.new(day: 14, minute: 5235, second: 5),
         | 
| 25 | 
            +
                      # 大寒(だいかん)・立冬(りっとう)
         | 
| 26 | 
            +
                      daikan: Cycle::Remainder.new(day: 14, minute: 6235, second: 5),
         | 
| 27 | 
            +
                      rittou: Cycle::Remainder.new(day: 14, minute: 6235, second: 5),
         | 
| 28 | 
            +
                      # 立春(りっしゅん)・霜降(そうこう)
         | 
| 29 | 
            +
                      risshun: Cycle::Remainder.new(day: 14, minute: 7235, second: 5),
         | 
| 30 | 
            +
                      soukou: Cycle::Remainder.new(day: 14, minute: 7235, second: 5),
         | 
| 31 | 
            +
                      # 雨水(うすい)・寒露(かんろ)
         | 
| 32 | 
            +
                      usui: Cycle::Remainder.new(day: 15, minute: 35, second: 5),
         | 
| 33 | 
            +
                      kanro: Cycle::Remainder.new(day: 15, minute: 35, second: 5),
         | 
| 34 | 
            +
                      # 啓蟄(けいちつ)・秋分(しゅうぶん)
         | 
| 35 | 
            +
                      keichitsu: Cycle::Remainder.new(day: 15, minute: 1235, second: 5),
         | 
| 36 | 
            +
                      shuubun: Cycle::Remainder.new(day: 15, minute: 1235, second: 5),
         | 
| 37 | 
            +
                      # 春分(しゅんぶん)・白露(はくろ)
         | 
| 38 | 
            +
                      shunbun: Cycle::Remainder.new(day: 15, minute: 2435, second: 5),
         | 
| 39 | 
            +
                      hakuro: Cycle::Remainder.new(day: 15, minute: 2435, second: 5),
         | 
| 40 | 
            +
                      # 清明(せいめい)・処暑(しょしょ)
         | 
| 41 | 
            +
                      seimei: Cycle::Remainder.new(day: 15, minute: 3635, second: 5),
         | 
| 42 | 
            +
                      shosho: Cycle::Remainder.new(day: 15, minute: 3635, second: 5),
         | 
| 43 | 
            +
                      # 穀雨(こくう)・立秋(りっしゅう)
         | 
| 44 | 
            +
                      kokuu: Cycle::Remainder.new(day: 15, minute: 4835, second: 5),
         | 
| 45 | 
            +
                      risshuu: Cycle::Remainder.new(day: 15, minute: 4835, second: 5),
         | 
| 46 | 
            +
                      # 立夏(りっか)・大暑(たいしょ)
         | 
| 47 | 
            +
                      rikka: Cycle::Remainder.new(day: 15, minute: 5835, second: 5),
         | 
| 48 | 
            +
                      taisho: Cycle::Remainder.new(day: 15, minute: 5835, second: 5),
         | 
| 49 | 
            +
                      # 小満(しょうまん)・小暑(しょうしょ)
         | 
| 50 | 
            +
                      shouman: Cycle::Remainder.new(day: 15, minute: 6835, second: 5),
         | 
| 51 | 
            +
                      shousho: Cycle::Remainder.new(day: 15, minute: 6835, second: 5),
         | 
| 52 | 
            +
                      # 芒種(ぼうしゅ)・夏至(げし)
         | 
| 53 | 
            +
                      boushu: Cycle::Remainder.new(day: 15, minute: 7835, second: 5),
         | 
| 54 | 
            +
                      geshi: Cycle::Remainder.new(day: 15, minute: 7835, second: 5)
         | 
| 55 | 
            +
                    }.freeze
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                    # @return [Array<Remainder>] 索引
         | 
| 58 | 
            +
                    INDEXES = [
         | 
| 59 | 
            +
                      LIST[:touji],      #  0
         | 
| 60 | 
            +
                      LIST[:shoukan],    #  1
         | 
| 61 | 
            +
                      LIST[:daikan],     #  2
         | 
| 62 | 
            +
                      LIST[:risshun],    #  3
         | 
| 63 | 
            +
                      LIST[:usui],       #  4
         | 
| 64 | 
            +
                      LIST[:keichitsu],  #  5
         | 
| 65 | 
            +
                      LIST[:shunbun],    #  6
         | 
| 66 | 
            +
                      LIST[:seimei],     #  7
         | 
| 67 | 
            +
                      LIST[:kokuu],      #  8
         | 
| 68 | 
            +
                      LIST[:rikka],      #  9
         | 
| 69 | 
            +
                      LIST[:shouman],    # 10
         | 
| 70 | 
            +
                      LIST[:boushu],     # 11
         | 
| 71 | 
            +
                      LIST[:geshi],      # 12
         | 
| 72 | 
            +
                      LIST[:shousho],    # 13
         | 
| 73 | 
            +
                      LIST[:taisho],     # 14
         | 
| 74 | 
            +
                      LIST[:risshuu],    # 15
         | 
| 75 | 
            +
                      LIST[:shosho],     # 16
         | 
| 76 | 
            +
                      LIST[:hakuro],     # 17
         | 
| 77 | 
            +
                      LIST[:shuubun],    # 18
         | 
| 78 | 
            +
                      LIST[:kanro],      # 19
         | 
| 79 | 
            +
                      LIST[:soukou],     # 20
         | 
| 80 | 
            +
                      LIST[:rittou],     # 21
         | 
| 81 | 
            +
                      LIST[:shousetsu],  # 22
         | 
| 82 | 
            +
                      LIST[:taisetsu]    # 23
         | 
| 83 | 
            +
                    ].freeze
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  #
         | 
| 87 | 
            +
                  # 入定気を計算する
         | 
| 88 | 
            +
                  #
         | 
| 89 | 
            +
                  # * 定気(index)の指定がない場合は、11月の入定気を求める
         | 
| 90 | 
            +
                  # * 定気(index)の指定がある場合は、大余小余から適切な入定気を再計算する
         | 
| 91 | 
            +
                  #
         | 
| 92 | 
            +
                  # @param [SolarTerm] solar_term 入定気
         | 
| 93 | 
            +
                  #
         | 
| 94 | 
            +
                  # @return [SolarTerm] 入定気
         | 
| 95 | 
            +
                  #
         | 
| 96 | 
            +
                  def self.get(solar_term:)
         | 
| 97 | 
            +
                    if solar_term.invalid?
         | 
| 98 | 
            +
                      return calc_first_solar_term(
         | 
| 99 | 
            +
                        winter_solstice_age: solar_term.remainder
         | 
| 100 | 
            +
                      )
         | 
| 101 | 
            +
                    end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                    calc_next_solar_term_recursively(
         | 
| 104 | 
            +
                      solar_term: solar_term
         | 
| 105 | 
            +
                    )
         | 
| 106 | 
            +
                  end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                  # :reek:TooManyStatements { max_statements: 7 }
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                  #
         | 
| 111 | 
            +
                  # 入定気(定気の開始点からの日時)と属する定気を計算する
         | 
| 112 | 
            +
                  #
         | 
| 113 | 
            +
                  # @param [Remainder] winter_solstice_age 天正冬至
         | 
| 114 | 
            +
                  #
         | 
| 115 | 
            +
                  # @return [SolarTerm] 二十四節気
         | 
| 116 | 
            +
                  #   SolarTerm.remainder : 入定気(定気の開始点からの日時)
         | 
| 117 | 
            +
                  #   SolarTerm.index : 定気
         | 
| 118 | 
            +
                  #
         | 
| 119 | 
            +
                  def self.calc_first_solar_term(winter_solstice_age:)
         | 
| 120 | 
            +
                    # 入定気の起算方法
         | 
| 121 | 
            +
                    # 概要:
         | 
| 122 | 
            +
                    #  * 太陽の運行による補正値は、二十四節気の気ごとに定められる
         | 
| 123 | 
            +
                    #  * 11月経朔の前にある気を求め、それから11月経朔との間隔を求める
         | 
| 124 | 
            +
                    #  * 気ごとの補正値と、気から11月経朔までにかかる補正値を求める
         | 
| 125 | 
            +
                    # 前提:
         | 
| 126 | 
            +
                    #  * 11月経朔に関わる二十四節気は、時系列から順に、小雪・大雪・冬至である
         | 
| 127 | 
            +
                    #  * 小雪〜大雪の間隔は小雪定数で、大雪〜冬至の間隔は大雪定数で決められている(24気損益眺朒(ちょうじく)数のこと)
         | 
| 128 | 
            +
                    #  * 11月経朔は、この小雪〜冬至の間のいずれかにある
         | 
| 129 | 
            +
                    # 計算:
         | 
| 130 | 
            +
                    # 2パターンある
         | 
| 131 | 
            +
                    #  (a) 大雪〜冬至にある場合
         | 
| 132 | 
            +
                    #   *「大雪定数 >= 天正閏余」の場合を指す
         | 
| 133 | 
            +
                    #   * * NOTE 資料では「より大きい(>)」とされるが、大雪そのものの場合は大雪から起算すべき
         | 
| 134 | 
            +
                    #   * この場合は、大雪〜経朔の間隔を求める
         | 
| 135 | 
            +
                    #  (b) 小雪〜大雪にある場合
         | 
| 136 | 
            +
                    #   *「大雪定数 < 天正閏余」の場合を指す
         | 
| 137 | 
            +
                    #   * この場合は、小雪〜経朔の間隔を求める
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                    # NOTE: 上記パターンとは別に、稀だが立冬のパターンも存在する
         | 
| 140 | 
            +
                    # この場合は比較方法はそのままに立冬〜経朔の間隔を求める
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                    rest = winter_solstice_age.clone
         | 
| 143 | 
            +
                    # 大雪(23)/小雪(22)/立冬(21)
         | 
| 144 | 
            +
                    [23, 22, 21].each do |index|
         | 
| 145 | 
            +
                      solar_term = prev_solar_term(winter_solstice_age: rest, index: index)
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                      if solar_term.invalid?
         | 
| 148 | 
            +
                        rest = solar_term.remainder
         | 
| 149 | 
            +
                        next
         | 
| 150 | 
            +
                      end
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                      return solar_term
         | 
| 153 | 
            +
                    end
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                    # 立冬(21)を超える天正閏余は成立し得ない(1朔望月をはるかに超えることになる)
         | 
| 156 | 
            +
                    raise ArgumentError.new, 'invalid winster solstice age'
         | 
| 157 | 
            +
                  end
         | 
| 158 | 
            +
                  private_class_method :calc_first_solar_term
         | 
| 159 | 
            +
             | 
| 160 | 
            +
                  #
         | 
| 161 | 
            +
                  # 入気定日加減数で入定気を遡る
         | 
| 162 | 
            +
                  #
         | 
| 163 | 
            +
                  # @param [Remainder] winter_solstice_age 天正冬至
         | 
| 164 | 
            +
                  # @param [Integer] index 二十四節気の連番
         | 
| 165 | 
            +
                  #
         | 
| 166 | 
            +
                  # @return [SolarTerm] 二十四節気
         | 
| 167 | 
            +
                  #   SolarTerm.remainder : 入定気(定気の開始点からの日時)
         | 
| 168 | 
            +
                  #   SolarTerm.index : 定気(範囲外であれば-1とする)
         | 
| 169 | 
            +
                  #
         | 
| 170 | 
            +
                  def self.prev_solar_term(winter_solstice_age:, index:)
         | 
| 171 | 
            +
                    interval = Interval::INDEXES[index]
         | 
| 172 | 
            +
                    if winter_solstice_age > interval
         | 
| 173 | 
            +
                      # 入定気が確定しない(さらに前の定気まで遡れる)
         | 
| 174 | 
            +
                      return Cycle::SolarTerm.new(
         | 
| 175 | 
            +
                        remainder: winter_solstice_age.sub(interval),
         | 
| 176 | 
            +
                        index: -1
         | 
| 177 | 
            +
                      )
         | 
| 178 | 
            +
                    end
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                    # 入定気が確定する
         | 
| 181 | 
            +
                    Cycle::SolarTerm.new(
         | 
| 182 | 
            +
                      remainder: interval.sub(winter_solstice_age),
         | 
| 183 | 
            +
                      index: index
         | 
| 184 | 
            +
                    )
         | 
| 185 | 
            +
                  end
         | 
| 186 | 
            +
                  private_class_method :prev_solar_term
         | 
| 187 | 
            +
             | 
| 188 | 
            +
                  # :reek:TooManyStatements { max_statements: 8 }
         | 
| 189 | 
            +
             | 
| 190 | 
            +
                  #
         | 
| 191 | 
            +
                  # 次の二十四節気を計算する
         | 
| 192 | 
            +
                  #
         | 
| 193 | 
            +
                  # @param [SolarTerm] solar_term 今回の二十四節気
         | 
| 194 | 
            +
                  #
         | 
| 195 | 
            +
                  # @return [SolarTerm] 次回の二十四節気
         | 
| 196 | 
            +
                  #
         | 
| 197 | 
            +
                  def self.calc_next_solar_term_recursively(solar_term:)
         | 
| 198 | 
            +
                    remainder = solar_term.remainder
         | 
| 199 | 
            +
                    index = solar_term.index
         | 
| 200 | 
            +
                    interval = Interval::INDEXES[index]
         | 
| 201 | 
            +
                    return solar_term if remainder < interval
         | 
| 202 | 
            +
             | 
| 203 | 
            +
                    remainder.sub!(interval)
         | 
| 204 | 
            +
                    index += 1
         | 
| 205 | 
            +
                    index = 0 if index >= Interval::INDEXES.size
         | 
| 206 | 
            +
                    calc_next_solar_term_recursively(
         | 
| 207 | 
            +
                      solar_term: Cycle::SolarTerm.new(remainder: remainder, index: index)
         | 
| 208 | 
            +
                    )
         | 
| 209 | 
            +
                  end
         | 
| 210 | 
            +
                  private_class_method :calc_next_solar_term_recursively
         | 
| 211 | 
            +
                end
         | 
| 212 | 
            +
              end
         | 
| 213 | 
            +
            end
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require_relative '../ | 
| 3 | 
            +
            require_relative '../cycle/solar_term'
         | 
| 4 4 |  | 
| 5 5 | 
             
            # :nodoc:
         | 
| 6 6 | 
             
            module Zakuro
         | 
| @@ -13,79 +13,6 @@ module Zakuro | |
| 13 13 | 
             
                  # @return [Integer] 統法(1日=8400分)
         | 
| 14 14 | 
             
                  DAY = 8400
         | 
| 15 15 |  | 
| 16 | 
            -
                  #
         | 
| 17 | 
            -
                  # Interval 入気定日加減数(二十四節気の間隔)
         | 
| 18 | 
            -
                  #
         | 
| 19 | 
            -
                  module Interval
         | 
| 20 | 
            -
                    # @return [Hash<Symbol, Remainder>] 一覧
         | 
| 21 | 
            -
                    LIST = {
         | 
| 22 | 
            -
                      # 冬至(とうじ)・大雪(たいせつ)
         | 
| 23 | 
            -
                      touji: Remainder.new(day: 14, minute: 4235, second: 5),
         | 
| 24 | 
            -
                      taisetsu: Remainder.new(day: 14, minute: 4235, second: 5),
         | 
| 25 | 
            -
                      # 小寒(しょうかん)・小雪(しょうせつ)
         | 
| 26 | 
            -
                      shoukan: Remainder.new(day: 14, minute: 5235, second: 5),
         | 
| 27 | 
            -
                      shousetsu: Remainder.new(day: 14, minute: 5235, second: 5),
         | 
| 28 | 
            -
                      # 大寒(だいかん)・立冬(りっとう)
         | 
| 29 | 
            -
                      daikan: Remainder.new(day: 14, minute: 6235, second: 5),
         | 
| 30 | 
            -
                      rittou: Remainder.new(day: 14, minute: 6235, second: 5),
         | 
| 31 | 
            -
                      # 立春(りっしゅん)・霜降(そうこう)
         | 
| 32 | 
            -
                      risshun: Remainder.new(day: 14, minute: 7235, second: 5),
         | 
| 33 | 
            -
                      soukou: Remainder.new(day: 14, minute: 7235, second: 5),
         | 
| 34 | 
            -
                      # 雨水(うすい)・寒露(かんろ)
         | 
| 35 | 
            -
                      usui: Remainder.new(day: 15, minute: 35, second: 5),
         | 
| 36 | 
            -
                      kanro: Remainder.new(day: 15, minute: 35, second: 5),
         | 
| 37 | 
            -
                      # 啓蟄(けいちつ)・秋分(しゅうぶん)
         | 
| 38 | 
            -
                      keichitsu: Remainder.new(day: 15, minute: 1235, second: 5),
         | 
| 39 | 
            -
                      shuubun: Remainder.new(day: 15, minute: 1235, second: 5),
         | 
| 40 | 
            -
                      # 春分(しゅんぶん)・白露(はくろ)
         | 
| 41 | 
            -
                      shunbun: Remainder.new(day: 15, minute: 2435, second: 5),
         | 
| 42 | 
            -
                      hakuro: Remainder.new(day: 15, minute: 2435, second: 5),
         | 
| 43 | 
            -
                      # 清明(せいめい)・処暑(しょしょ)
         | 
| 44 | 
            -
                      seimei: Remainder.new(day: 15, minute: 3635, second: 5),
         | 
| 45 | 
            -
                      shosho: Remainder.new(day: 15, minute: 3635, second: 5),
         | 
| 46 | 
            -
                      # 穀雨(こくう)・立秋(りっしゅう)
         | 
| 47 | 
            -
                      kokuu: Remainder.new(day: 15, minute: 4835, second: 5),
         | 
| 48 | 
            -
                      risshuu: Remainder.new(day: 15, minute: 4835, second: 5),
         | 
| 49 | 
            -
                      # 立夏(りっか)・大暑(たいしょ)
         | 
| 50 | 
            -
                      rikka: Remainder.new(day: 15, minute: 5835, second: 5),
         | 
| 51 | 
            -
                      taisho: Remainder.new(day: 15, minute: 5835, second: 5),
         | 
| 52 | 
            -
                      # 小満(しょうまん)・小暑(しょうしょ)
         | 
| 53 | 
            -
                      shouman: Remainder.new(day: 15, minute: 6835, second: 5),
         | 
| 54 | 
            -
                      shousho: Remainder.new(day: 15, minute: 6835, second: 5),
         | 
| 55 | 
            -
                      # 芒種(ぼうしゅ)・夏至(げし)
         | 
| 56 | 
            -
                      boushu: Remainder.new(day: 15, minute: 7835, second: 5),
         | 
| 57 | 
            -
                      geshi: Remainder.new(day: 15, minute: 7835, second: 5)
         | 
| 58 | 
            -
                    }.freeze
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                    # @return [Array<Remainder>] 索引
         | 
| 61 | 
            -
                    INDEXES = [
         | 
| 62 | 
            -
                      LIST[:touji],      #  0
         | 
| 63 | 
            -
                      LIST[:shoukan],    #  1
         | 
| 64 | 
            -
                      LIST[:daikan],     #  2
         | 
| 65 | 
            -
                      LIST[:risshun],    #  3
         | 
| 66 | 
            -
                      LIST[:usui],       #  4
         | 
| 67 | 
            -
                      LIST[:keichitsu],  #  5
         | 
| 68 | 
            -
                      LIST[:shunbun],    #  6
         | 
| 69 | 
            -
                      LIST[:seimei],     #  7
         | 
| 70 | 
            -
                      LIST[:kokuu],      #  8
         | 
| 71 | 
            -
                      LIST[:rikka],      #  9
         | 
| 72 | 
            -
                      LIST[:shouman],    # 10
         | 
| 73 | 
            -
                      LIST[:boushu],     # 11
         | 
| 74 | 
            -
                      LIST[:geshi],      # 12
         | 
| 75 | 
            -
                      LIST[:shousho],    # 13
         | 
| 76 | 
            -
                      LIST[:taisho],     # 14
         | 
| 77 | 
            -
                      LIST[:risshuu],    # 15
         | 
| 78 | 
            -
                      LIST[:shosho],     # 16
         | 
| 79 | 
            -
                      LIST[:hakuro],     # 17
         | 
| 80 | 
            -
                      LIST[:shuubun],    # 18
         | 
| 81 | 
            -
                      LIST[:kanro],      # 19
         | 
| 82 | 
            -
                      LIST[:soukou],     # 20
         | 
| 83 | 
            -
                      LIST[:rittou],     # 21
         | 
| 84 | 
            -
                      LIST[:shousetsu],  # 22
         | 
| 85 | 
            -
                      LIST[:taisetsu]    # 23
         | 
| 86 | 
            -
                    ].freeze
         | 
| 87 | 
            -
                  end
         | 
| 88 | 
            -
             | 
| 89 16 | 
             
                  #
         | 
| 90 17 | 
             
                  # 24気損益眺朒(ちょうじく)数
         | 
| 91 18 | 
             
                  #
         | 
| @@ -153,118 +80,10 @@ module Zakuro | |
| 153 80 | 
             
                    }.freeze
         | 
| 154 81 | 
             
                  end
         | 
| 155 82 |  | 
| 156 | 
            -
                  #
         | 
| 157 | 
            -
                  # 二十四節気 と 補正値 を計算する
         | 
| 158 | 
            -
                  #
         | 
| 159 | 
            -
                  # @param [SolarTerm] solar_term 二十四節気
         | 
| 160 | 
            -
                  #
         | 
| 161 | 
            -
                  # @return [SolarTerm] 二十四節気
         | 
| 162 | 
            -
                  # @return [Integer] 補正値
         | 
| 163 | 
            -
                  #
         | 
| 164 | 
            -
                  def self.calc_term_and_orbit_value(solar_term:)
         | 
| 165 | 
            -
                    remainder = calc_solar_term_by_remainder(
         | 
| 166 | 
            -
                      solar_term: solar_term
         | 
| 167 | 
            -
                    )
         | 
| 168 | 
            -
                    value = calc_sun_orbit_value(
         | 
| 169 | 
            -
                      solar_term: remainder
         | 
| 170 | 
            -
                    )
         | 
| 171 | 
            -
                    [remainder, value]
         | 
| 172 | 
            -
                  end
         | 
| 173 | 
            -
             | 
| 174 | 
            -
                  # :reek:ControlParameter and :reek:BooleanParameter
         | 
| 175 | 
            -
             | 
| 176 | 
            -
                  #
         | 
| 177 | 
            -
                  # 二十四節気を計算する
         | 
| 178 | 
            -
                  #
         | 
| 179 | 
            -
                  # @param [SolarTerm] solar_term 二十四節気
         | 
| 180 | 
            -
                  #
         | 
| 181 | 
            -
                  # @return [SolarTerm] 二十四節気
         | 
| 182 | 
            -
                  #
         | 
| 183 | 
            -
                  def self.calc_solar_term_by_remainder(solar_term:)
         | 
| 184 | 
            -
                    if solar_term.index.negative?
         | 
| 185 | 
            -
                      return calc_first_solar_term(
         | 
| 186 | 
            -
                        winter_solstice_age: solar_term.remainder
         | 
| 187 | 
            -
                      )
         | 
| 188 | 
            -
                    end
         | 
| 189 | 
            -
             | 
| 190 | 
            -
                    calc_next_solar_term_recursively(
         | 
| 191 | 
            -
                      solar_term: solar_term
         | 
| 192 | 
            -
                    )
         | 
| 193 | 
            -
                  end
         | 
| 194 | 
            -
             | 
| 195 | 
            -
                  # :reek:TooManyStatements { max_statements: 8 }
         | 
| 196 | 
            -
             | 
| 197 | 
            -
                  #
         | 
| 198 | 
            -
                  # 入定気(定気の開始点からの日時)と属する定気を計算する
         | 
| 199 | 
            -
                  #
         | 
| 200 | 
            -
                  # @param [Remainder] winter_solstice_age 天正冬至
         | 
| 201 | 
            -
                  #
         | 
| 202 | 
            -
                  # @return [SolarTerm] 二十四節気
         | 
| 203 | 
            -
                  #   SolarTerm.remainder : 入定気(定気の開始点からの日時)
         | 
| 204 | 
            -
                  #   SolarTerm.index : 定気
         | 
| 205 | 
            -
                  #
         | 
| 206 | 
            -
                  def self.calc_first_solar_term(winter_solstice_age:)
         | 
| 207 | 
            -
                    # 入定気の起算方法
         | 
| 208 | 
            -
                    # 概要:
         | 
| 209 | 
            -
                    #  * 太陽の運行による補正値は、二十四節気の気ごとに定められる
         | 
| 210 | 
            -
                    #  * 11月経朔の前にある気を求め、それから11月経朔との間隔を求める
         | 
| 211 | 
            -
                    #  * 気ごとの補正値と、気から11月経朔までにかかる補正値を求める
         | 
| 212 | 
            -
                    # 前提:
         | 
| 213 | 
            -
                    #  * 11月経朔に関わる二十四節気は、時系列から順に、小雪・大雪・冬至である
         | 
| 214 | 
            -
                    #  * 小雪〜大雪の間隔は小雪定数で、大雪〜冬至の間隔は大雪定数で決められている(24気損益眺朒(ちょうじく)数のこと)
         | 
| 215 | 
            -
                    #  * 11月経朔は、この小雪〜冬至の間のいずれかにある
         | 
| 216 | 
            -
                    # 計算:
         | 
| 217 | 
            -
                    # 2パターンある
         | 
| 218 | 
            -
                    #  (a) 大雪〜冬至にある場合
         | 
| 219 | 
            -
                    #   *「大雪定数 >= 天正閏余」の場合を指す
         | 
| 220 | 
            -
                    #   * * NOTE 資料では「より大きい(>)」とされるが、大雪そのものの場合は大雪から起算すべき
         | 
| 221 | 
            -
                    #   * この場合は、大雪〜経朔の間隔を求める
         | 
| 222 | 
            -
                    #  (b) 小雪〜大雪にある場合
         | 
| 223 | 
            -
                    #   *「大雪定数 < 天正閏余」の場合を指す
         | 
| 224 | 
            -
                    #   * この場合は、小雪〜経朔の間隔を求める
         | 
| 225 | 
            -
                    taisetsu = 23
         | 
| 226 | 
            -
                    taisetsu_interval = Interval::INDEXES[taisetsu]
         | 
| 227 | 
            -
             | 
| 228 | 
            -
                    if winter_solstice_age > taisetsu_interval
         | 
| 229 | 
            -
                      # (b)
         | 
| 230 | 
            -
                      shousetsu = 22
         | 
| 231 | 
            -
                      diff = winter_solstice_age.sub(taisetsu_interval)
         | 
| 232 | 
            -
             | 
| 233 | 
            -
                      return SolarTerm.new(remainder: Interval::INDEXES[shousetsu].sub(diff),
         | 
| 234 | 
            -
                                           index: shousetsu)
         | 
| 235 | 
            -
                    end
         | 
| 236 | 
            -
                    # (a)
         | 
| 237 | 
            -
                    SolarTerm.new(remainder: taisetsu_interval.sub(winter_solstice_age),
         | 
| 238 | 
            -
                                  index: taisetsu)
         | 
| 239 | 
            -
                  end
         | 
| 240 | 
            -
             | 
| 241 | 
            -
                  # :reek:TooManyStatements { max_statements: 8 }
         | 
| 242 | 
            -
             | 
| 243 | 
            -
                  #
         | 
| 244 | 
            -
                  # 次の二十四節気を計算する
         | 
| 245 | 
            -
                  #
         | 
| 246 | 
            -
                  # @param [SolarTerm] solar_term 今回の二十四節気
         | 
| 247 | 
            -
                  #
         | 
| 248 | 
            -
                  # @return [SolarTerm] 次回の二十四節気
         | 
| 249 | 
            -
                  #
         | 
| 250 | 
            -
                  def self.calc_next_solar_term_recursively(solar_term:)
         | 
| 251 | 
            -
                    remainder = solar_term.remainder
         | 
| 252 | 
            -
                    index = solar_term.index
         | 
| 253 | 
            -
                    interval = Interval::INDEXES[index]
         | 
| 254 | 
            -
                    return solar_term if remainder < interval
         | 
| 255 | 
            -
             | 
| 256 | 
            -
                    remainder.sub!(interval)
         | 
| 257 | 
            -
                    index += 1
         | 
| 258 | 
            -
                    index = 0 if index >= Interval::INDEXES.size
         | 
| 259 | 
            -
                    calc_next_solar_term_recursively(
         | 
| 260 | 
            -
                      solar_term: SolarTerm.new(remainder: remainder, index: index)
         | 
| 261 | 
            -
                    )
         | 
| 262 | 
            -
                  end
         | 
| 263 | 
            -
             | 
| 264 83 | 
             
                  #
         | 
| 265 84 | 
             
                  # 太陽の運行による補正値を算出する
         | 
| 266 85 | 
             
                  #
         | 
| 267 | 
            -
                  # @param [SolarTerm] solar_term  | 
| 86 | 
            +
                  # @param [SolarTerm] solar_term 入定気
         | 
| 268 87 | 
             
                  #
         | 
| 269 88 | 
             
                  # @return [Integer] 補正値
         | 
| 270 89 | 
             
                  #
         | 
| @@ -315,7 +134,7 @@ module Zakuro | |
| 315 134 | 
             
                  # @return [Adjustment::Item] 24気損益眺朒(ちょうじく)数
         | 
| 316 135 | 
             
                  #
         | 
| 317 136 | 
             
                  def self.specify_solar_term_adjustment(index:)
         | 
| 318 | 
            -
                    key = SolarTerm::ORDER[index]
         | 
| 137 | 
            +
                    key = Cycle::SolarTerm::ORDER[index]
         | 
| 319 138 | 
             
                    Adjustment::LIST[key].clone
         | 
| 320 139 | 
             
                  end
         | 
| 321 140 | 
             
                  private_class_method :specify_solar_term_adjustment
         | 
| @@ -27,8 +27,8 @@ module Zakuro | |
| 27 27 | 
             
                  # @return [Integer] 暦の開始年(長慶2年)
         | 
| 28 28 | 
             
                  BEGIN_YEAR = 822
         | 
| 29 29 |  | 
| 30 | 
            -
                  # @return [Logger] ロガー
         | 
| 31 | 
            -
                  LOGGER = Logger.new(location: 'winter_solstice')
         | 
| 30 | 
            +
                  # @return [Output::Logger] ロガー
         | 
| 31 | 
            +
                  LOGGER = Output::Logger.new(location: 'winter_solstice')
         | 
| 32 32 |  | 
| 33 33 | 
             
                  # :reek:TooManyStatements { max_statements: 6 }
         | 
| 34 34 |  | 
| @@ -51,7 +51,7 @@ module Zakuro | |
| 51 51 |  | 
| 52 52 | 
             
                    LOGGER.debug("[a02]:#{winter_solstice_minute}")
         | 
| 53 53 |  | 
| 54 | 
            -
                    Remainder.new(total: winter_solstice_minute)
         | 
| 54 | 
            +
                    Cycle::Remainder.new(total: winter_solstice_minute)
         | 
| 55 55 | 
             
                  end
         | 
| 56 56 |  | 
| 57 57 | 
             
                  # :reek:TooManyStatements { max_statements: 7 }
         | 
| @@ -82,7 +82,7 @@ module Zakuro | |
| 82 82 | 
             
                    LOGGER.debug("[b02]: #{winter_solstice_age}")
         | 
| 83 83 |  | 
| 84 84 | 
             
                    # 大余・小余に変換する
         | 
| 85 | 
            -
                    Remainder.new(total: winter_solstice_age)
         | 
| 85 | 
            +
                    Cycle::Remainder.new(total: winter_solstice_age)
         | 
| 86 86 | 
             
                  end
         | 
| 87 87 |  | 
| 88 88 | 
             
                  #
         |