Class: Astronoby::EclipsePhase

Inherits:
Object
  • Object
show all
Defined in:
lib/astronoby/events/eclipse_phase.rb

Overview

A bounded phase of an eclipse, delimited by its two boundary instants.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(starting_instant:, ending_instant:) ⇒ EclipsePhase

Returns a new instance of EclipsePhase.

Parameters:



14
15
16
17
18
# File 'lib/astronoby/events/eclipse_phase.rb', line 14

def initialize(starting_instant:, ending_instant:)
  @starting_instant = starting_instant
  @ending_instant = ending_instant
  freeze
end

Instance Attribute Details

#ending_instantAstronoby::Instant (readonly)

Returns when the phase ends.

Returns:



10
11
12
# File 'lib/astronoby/events/eclipse_phase.rb', line 10

def ending_instant
  @ending_instant
end

#starting_instantAstronoby::Instant (readonly)

Returns when the phase begins.

Returns:



7
8
9
# File 'lib/astronoby/events/eclipse_phase.rb', line 7

def starting_instant
  @starting_instant
end

Instance Method Details

#durationAstronoby::Duration

Returns phase duration.

Returns:



21
22
23
24
25
# File 'lib/astronoby/events/eclipse_phase.rb', line 21

def duration
  Duration.from_seconds(
    (@ending_instant.to_time - @starting_instant.to_time).round
  )
end