Class: Zakuro::Calculation::Monthly::AbstractLunarPhase

Inherits:
Object
  • Object
show all
Defined in:
lib/zakuro/calculation/monthly/abstract_lunar_phase.rb

Overview

AbstractLunarPhase 月の位相

Constant Summary collapse

LOGGER =

Returns ロガー.

Returns:

Output::Logger.new(location: 'lunar_phase')
PHASE_INDEXES =

Returns 月内の弦.

Returns:

  • (Array<String>)

    月内の弦

Const::PHASE_INDEXES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(quarter:, average_remainder:, solar_location:, lunar_location:) ⇒ AbstractLunarPhase

初期化

Parameters:



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 42

def initialize(quarter:, average_remainder:, solar_location:, lunar_location:)
  # 弦
  @quarter = quarter
  # 経
  @average_remainder = average_remainder
  # 入定気
  @solar_location = solar_location
  # 入暦
  @lunar_location = lunar_location

  # 弦の位置
  @index = 0
end

Instance Attribute Details

#average_remainderCycle::AbstractRemainder (readonly)

Returns 経.

Returns:



26
27
28
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 26

def average_remainder
  @average_remainder
end

#indexInteger (readonly)

Returns 弦の位置.

Returns:

  • (Integer)

    弦の位置



32
33
34
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 32

def index
  @index
end

#lunar_locationLunar::AbstractLocation (readonly)

Returns 入暦.

Returns:



30
31
32
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 30

def lunar_location
  @lunar_location
end

#quarterCycle::AbstractRemainder (readonly)

Returns 弦.

Returns:



24
25
26
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 24

def quarter
  @quarter
end

#solar_locationSolar::AbstractLocation (readonly)

Returns 入定気.

Returns:



28
29
30
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 28

def solar_location
  @solar_location
end

Instance Method Details

#next_monthRemainder

Note:

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

次の月に進める

Returns:

  • (Remainder)

    当月初の定朔



75
76
77
78
79
80
81
82
83
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 75

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_phaseRemainder

次の弦に進める

Returns:

  • (Remainder)

    定朔



61
62
63
64
65
66
67
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 61

def next_phase
  adjusted = current_remainder

  add_quarter_moon_size

  adjusted
end