Class: Astronoby::EclipsePhase
- Inherits:
-
Object
- Object
- Astronoby::EclipsePhase
- 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
-
#ending_instant ⇒ Astronoby::Instant
readonly
When the phase ends.
-
#starting_instant ⇒ Astronoby::Instant
readonly
When the phase begins.
Instance Method Summary collapse
-
#duration ⇒ Astronoby::Duration
Phase duration.
-
#initialize(starting_instant:, ending_instant:) ⇒ EclipsePhase
constructor
A new instance of EclipsePhase.
Constructor Details
#initialize(starting_instant:, ending_instant:) ⇒ EclipsePhase
Returns a new instance of EclipsePhase.
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_instant ⇒ Astronoby::Instant (readonly)
Returns when the phase ends.
10 11 12 |
# File 'lib/astronoby/events/eclipse_phase.rb', line 10 def ending_instant @ending_instant end |
#starting_instant ⇒ Astronoby::Instant (readonly)
Returns when the phase begins.
7 8 9 |
# File 'lib/astronoby/events/eclipse_phase.rb', line 7 def starting_instant @starting_instant end |
Instance Method Details
#duration ⇒ Astronoby::Duration
Returns phase duration.
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 |