class Zakuro::Calculation::Monthly::AbstractLunarPhase

AbstractLunarPhase 月の位相

Constants

LOGGER

@return [Output::Logger] ロガー

PHASE_INDEXES

@return [Array<String>] 月内の弦

Attributes

average_remainder[R]

@return [Cycle::AbstractRemainder] 経

index[R]

@return [Integer] 弦の位置

lunar_location[R]

@return [Lunar::AbstractLocation] 入暦

solar_location[R]

@return [Solar::AbstractLocation] 入定気

Public Class Methods

new(quater:, average_remainder:, solar_location:, lunar_location:) click to toggle source

初期化

@param [Cycle::AbstractRemainder] quater 弦 @param [Solar::AbstractLocation] average_remainder 経 @param [Solar::AbstractLocation] solar_location 入定気 @param [Lunar::AbstractLocation] lunar_location 入暦

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 38
def initialize(quater:, average_remainder:, solar_location:, lunar_location:)
  # 弦
  @quarter = quater
  # 経
  @average_remainder = average_remainder
  # 入定気
  @solar_location = solar_location
  # 入暦
  @lunar_location = lunar_location

  # 弦の位置
  @index = 0
end

Public Instance Methods

next_month() click to toggle source

次の月に進める @note 進めた後の月の定朔ではなく、当月のものを返却する

@return [Remainder] 当月初の定朔

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 71
def next_month
  result = nil
  PHASE_INDEXES.each_with_index do |_phase, index|
    adjust = next_phase
    result = adjust if index.zero?
  end

  result
end
next_phase() click to toggle source

次の弦に進める

@return [Remainder] 定朔

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 57
def next_phase
  adjusted = current_remainder

  add_quarter_moon_size

  adjusted
end

Private Instance Methods

add_quarter_moon_size() click to toggle source
# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 159
def add_quarter_moon_size
  @average_remainder.add!(@quarter)
  @solar_location.add_quarter
  @lunar_location.add_quarter

  next_index
end
correction_moon_value() click to toggle source

月運動の補正値を得る

@return [Integer] 月運動の補正値

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 155
def correction_moon_value
  # abstract
end
correction_solar_value() click to toggle source

太陽運動の補正値を得る

@return [Integer] 太陽運動の補正値

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 146
def correction_solar_value
  # abstract
end
correction_value() click to toggle source

補正値を得る

@return [Integer] 補正値

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 130
def correction_value
  sun = correction_solar_value
  moon = correction_moon_value

  sum = sun + moon

  debug("sun: #{sun}", "moon: #{moon}", "sun + moon : #{sum}")

  sum
end
current_remainder() click to toggle source

現在の定朔を取得する

@return [Remainder] 定朔

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 121
def current_remainder
  # abstract
end
debug(*messages) click to toggle source

朔月のみログ出力する

@param [String] messages メッセージ(可変長)

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 109
def debug(*messages)
  # 全ての弦を対象にするためコメントアウトする
  # return unless first_phase?

  LOGGER.debug(*messages)
end
first_phase?() click to toggle source

朔月(月初)であるか

@return [True] 朔月である @return [False] 朔月ではない

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 100
def first_phase?
  @index.zero?
end
next_index() click to toggle source

次の弦に進める

@return [Integer] 弦

# File lib/zakuro/calculation/monthly/abstract_lunar_phase.rb, line 88
def next_index
  @index += 1
  @index = 0 if @index >= PHASE_INDEXES.size
  @index
end