Class: Astronoby::Events::MoonPhases
- Inherits:
-
Object
- Object
- Astronoby::Events::MoonPhases
- Defined in:
- lib/astronoby/events/moon_phases.rb
Constant Summary collapse
- BASE_YEAR =
2000
Class Method Summary collapse
-
.phases_for(year:, month:) ⇒ Array<Astronoby::MoonPhase>
List of Moon phases.
Instance Method Summary collapse
-
#initialize(year, month, phase, phase_increment) ⇒ MoonPhases
constructor
A new instance of MoonPhases.
-
#time ⇒ Time
Time of the Moon phase.
Constructor Details
#initialize(year, month, phase, phase_increment) ⇒ MoonPhases
Returns a new instance of MoonPhases.
34 35 36 37 38 39 |
# File 'lib/astronoby/events/moon_phases.rb', line 34 def initialize(year, month, phase, phase_increment) @year = year @month = month @phase = phase @phase_increment = phase_increment end |
Class Method Details
.phases_for(year:, month:) ⇒ Array<Astronoby::MoonPhase>
Returns List of Moon phases.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/astronoby/events/moon_phases.rb', line 17 def self.phases_for(year:, month:) [ MoonPhase.first_quarter(new(year, month, :first_quarter, -0.75).time), MoonPhase.full_moon(new(year, month, :full_moon, -0.5).time), MoonPhase.last_quarter(new(year, month, :last_quarter, -0.25).time), MoonPhase.new_moon(new(year, month, :new_moon, 0).time), MoonPhase.first_quarter(new(year, month, :first_quarter, 0.25).time), MoonPhase.full_moon(new(year, month, :full_moon, 0.5).time), MoonPhase.last_quarter(new(year, month, :last_quarter, 0.75).time), MoonPhase.new_moon(new(year, month, :new_moon, 1).time) ].select { _1.time.month == month } end |
Instance Method Details
#time ⇒ Time
Returns Time of the Moon phase.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/astronoby/events/moon_phases.rb', line 42 def time correction = moon_phases_periodic_terms .public_send(:"#{@phase}_correction") terrestrial_time = Epoch.to_utc( julian_ephemeris_day + correction + moon_phases_periodic_terms.additional_corrections ) delta = Util::Time.terrestrial_universal_time_delta(terrestrial_time) (terrestrial_time - delta).round end |