Class: Zakuro::Calculation::Monthly::AbstractLunarPhase
- Inherits:
-
Object
- Object
- Zakuro::Calculation::Monthly::AbstractLunarPhase
- Defined in:
- lib/zakuro/calculation/monthly/abstract_lunar_phase.rb
Overview
AbstractLunarPhase 月の位相
Direct Known Subclasses
Version::Daien::Monthly::LunarPhase, Version::Gihou::Monthly::LunarPhase, Version::Senmyou::Monthly::LunarPhase
Constant Summary collapse
- LOGGER =
Returns ロガー.
Output::Logger.new(location: 'lunar_phase')
- PHASE_INDEXES =
Returns 月内の弦.
Const::PHASE_INDEXES
Instance Attribute Summary collapse
-
#average_remainder ⇒ Cycle::AbstractRemainder
readonly
経.
-
#index ⇒ Integer
readonly
弦の位置.
-
#lunar_location ⇒ Lunar::AbstractLocation
readonly
入暦.
-
#quarter ⇒ Cycle::AbstractRemainder
readonly
弦.
-
#solar_location ⇒ Solar::AbstractLocation
readonly
入定気.
Instance Method Summary collapse
-
#initialize(quarter:, average_remainder:, solar_location:, lunar_location:) ⇒ AbstractLunarPhase
constructor
初期化.
-
#next_month ⇒ Remainder
次の月に進める.
-
#next_phase ⇒ Remainder
次の弦に進める.
Constructor Details
#initialize(quarter:, average_remainder:, solar_location:, lunar_location:) ⇒ AbstractLunarPhase
初期化
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_remainder ⇒ Cycle::AbstractRemainder (readonly)
Returns 経.
26 27 28 |
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 26 def average_remainder @average_remainder end |
#index ⇒ Integer (readonly)
Returns 弦の位置.
32 33 34 |
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 32 def index @index end |
#lunar_location ⇒ Lunar::AbstractLocation (readonly)
Returns 入暦.
30 31 32 |
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 30 def lunar_location @lunar_location end |
#quarter ⇒ Cycle::AbstractRemainder (readonly)
Returns 弦.
24 25 26 |
# File 'lib/zakuro/calculation/monthly/abstract_lunar_phase.rb', line 24 def quarter @quarter end |
#solar_location ⇒ Solar::AbstractLocation (readonly)
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_month ⇒ Remainder
Note:
進めた後の月の定朔ではなく、当月のものを返却する
次の月に進める
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_phase ⇒ 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 |