class Zakuro::Senmyou::Lunar::Location

Location 入暦

Constants

HALF_ANOMALISTIC_MONTH

@return [Cycle::LunarRemainder] 暦中日(1近点月の半分)

QUARTER

@return [Cycle::LunarRemainder] 弦

Attributes

forward[R]

@return [True] 進 @return [False] 退

Public Class Methods

new(lunar_age:, western_year:) click to toggle source

初期化

@param [Cycle::LunarRemainder] lunar_age 天正閏余(大余小余) @param [Integer] western_year 西暦年

# File lib/zakuro/version/senmyou/stella/lunar/location.rb, line 34
def initialize(lunar_age:, western_year:)
  super(lunar_age: lunar_age, western_year: western_year)
  # 進
  @forward = true
end

Public Instance Methods

add_quarter() click to toggle source

弦の分だけ月地点を進める

# File lib/zakuro/version/senmyou/stella/lunar/location.rb, line 55
def add_quarter
  remainder.add!(QUARTER)
end
run() click to toggle source

入暦を計算する

# File lib/zakuro/version/senmyou/stella/lunar/location.rb, line 43
def run
  if calculated
    decrease(limit: HALF_ANOMALISTIC_MONTH)
    return
  end

  first
end

Private Instance Methods

decrease(limit:) click to toggle source

大余小余に合わせて減算する(折り返す)

@param [Cycle::LunarRemainder] limit 上限

# File lib/zakuro/version/senmyou/stella/lunar/location.rb, line 78
def decrease(limit:)
  return if remainder < limit

  remainder.sub!(limit)
  @forward = !forward
end
first() click to toggle source

初回計算

# File lib/zakuro/version/senmyou/stella/lunar/location.rb, line 64
def first
  @remainder = Localization.first_remainder(
    lunar_age: remainder, western_year: western_year
  )
  decrease(limit: HALF_ANOMALISTIC_MONTH)

  @calculated = true
end