Class: Ephem::Segments::SegmentGroup
- Inherits:
-
Object
- Object
- Ephem::Segments::SegmentGroup
- Defined in:
- lib/ephem/segments/segment_group.rb
Overview
Several segments that share the same key (an SPK center/target pair, or a PCK body) but cover different, contiguous time intervals. Each query is routed to the segment covering the requested time, so a body that a kernel splits across several intervals behaves as a single, continuous source.
SPK and PCK only build a group when a key actually has more than one segment; the common single-segment case returns the bare segment, so this routing never sits in the hot path for it.
Subclasses (PositionGroup, OrientationGroup) add the query methods appropriate to the segments they hold.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#segments ⇒ Array<BaseSegment>
readonly
The underlying segments.
Class Method Summary collapse
-
.wrap(segments) ⇒ BaseSegment, SegmentGroup
Wraps segments that share a key.
Instance Method Summary collapse
-
#clear_data ⇒ void
Clears cached data for every segment in the group.
-
#initialize(segments) ⇒ SegmentGroup
constructor
A new instance of SegmentGroup.
- #to_s ⇒ Object
Constructor Details
#initialize(segments) ⇒ SegmentGroup
Returns a new instance of SegmentGroup.
31 32 33 |
# File 'lib/ephem/segments/segment_group.rb', line 31 def initialize(segments) @segments = segments end |
Instance Attribute Details
#segments ⇒ Array<BaseSegment> (readonly)
Returns the underlying segments.
28 29 30 |
# File 'lib/ephem/segments/segment_group.rb', line 28 def segments @segments end |
Class Method Details
.wrap(segments) ⇒ BaseSegment, SegmentGroup
Wraps segments that share a key. A single segment is returned as-is, so the common case carries no routing overhead; only a key spanning several time intervals becomes a group.
23 24 25 |
# File 'lib/ephem/segments/segment_group.rb', line 23 def self.wrap(segments) segments.one? ? segments.first : new(segments) end |
Instance Method Details
#clear_data ⇒ void
This method returns an undefined value.
Clears cached data for every segment in the group.
38 39 40 |
# File 'lib/ephem/segments/segment_group.rb', line 38 def clear_data @segments.each(&:clear_data) end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/ephem/segments/segment_group.rb', line 42 def to_s @segments.join("\n") end |