Class: Ephem::Segments::BaseSegment
- Inherits:
-
Object
- Object
- Ephem::Segments::BaseSegment
- Includes:
- Core::CalendarCalculations, Core::Constants
- Defined in:
- lib/ephem/segments/base_segment.rb
Direct Known Subclasses
Constant Summary collapse
- TARGET_NAMES =
{ Bodies::SOLAR_SYSTEM_BARYCENTER => "Solar System Barycenter", Bodies::MERCURY_BARYCENTER => "Mercury Barycenter", Bodies::VENUS_BARYCENTER => "Venus Barycenter", Bodies::EARTH_MOON_BARYCENTER => "Earth-Moon Barycenter", Bodies::MARS_BARYCENTER => "Mars Barycenter", Bodies::JUPITER_BARYCENTER => "Jupiter Barycenter", Bodies::SATURN_BARYCENTER => "Saturn Barycenter", Bodies::URANUS_BARYCENTER => "Uranus Barycenter", Bodies::NEPTUNE_BARYCENTER => "Neptune Barycenter", Bodies::PLUTO_BARYCENTER => "Pluto Barycenter", Bodies::SUN => "Sun", Bodies::MERCURY => "Mercury", Bodies::VENUS => "Venus", Bodies::MOON => "Moon", Bodies::EARTH => "Earth", Bodies::MARS => "Mars", Bodies::JUPITER => "Jupiter", Bodies::SATURN => "Saturn", Bodies::URANUS => "Uranus", Bodies::NEPTUNE => "Neptune", Bodies::PLUTO => "Pluto" }.freeze
Instance Attribute Summary collapse
-
#center ⇒ Integer
readonly
The center body ID.
-
#daf ⇒ Ephem::IO::DAF
readonly
The DAF object representing the data file.
-
#source ⇒ String
readonly
The source of the segment.
-
#target ⇒ Integer
readonly
The target body ID.
Instance Method Summary collapse
- #clear_data ⇒ Object
- #compute(_tdb, _tdb2 = 0.0) ⇒ Object
- #compute_and_differentiate(_tdb, _tdb2 = 0.0) ⇒ Object
-
#describe(verbose: false) ⇒ String
Detailed description of the segment.
-
#initialize(daf:, source:, descriptor:) ⇒ BaseSegment
constructor
Initialize a new segment.
-
#to_s ⇒ String
String representation of the segment.
Methods included from Core::CalendarCalculations
format_date, julian_to_gregorian
Constructor Details
#initialize(daf:, source:, descriptor:) ⇒ BaseSegment
Initialize a new segment
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ephem/segments/base_segment.rb', line 55 def initialize(daf:, source:, descriptor:) @daf = daf @source = source @start_second, @end_second, @target, @center, @frame, @data_type, @start_i, @end_i = descriptor @start_jd = compute_julian_date(@start_second) @end_jd = compute_julian_date(@end_second) end |
Instance Attribute Details
#center ⇒ Integer (readonly)
Returns the center body ID.
38 39 40 |
# File 'lib/ephem/segments/base_segment.rb', line 38 def center @center end |
#daf ⇒ Ephem::IO::DAF (readonly)
Returns the DAF object representing the data file.
34 35 36 |
# File 'lib/ephem/segments/base_segment.rb', line 34 def daf @daf end |
#source ⇒ String (readonly)
Returns the source of the segment.
40 41 42 |
# File 'lib/ephem/segments/base_segment.rb', line 40 def source @source end |
#target ⇒ Integer (readonly)
Returns the target body ID.
36 37 38 |
# File 'lib/ephem/segments/base_segment.rb', line 36 def target @target end |
Instance Method Details
#clear_data ⇒ Object
110 111 112 |
# File 'lib/ephem/segments/base_segment.rb', line 110 def clear_data # Placeholder method to clear any cached data end |
#compute(_tdb, _tdb2 = 0.0) ⇒ Object
100 101 102 103 |
# File 'lib/ephem/segments/base_segment.rb', line 100 def compute(_tdb, _tdb2 = 0.0) raise NotImplementedError, "#{self.class} has not implemented compute() for data type #{@data_type}" end |
#compute_and_differentiate(_tdb, _tdb2 = 0.0) ⇒ Object
105 106 107 108 |
# File 'lib/ephem/segments/base_segment.rb', line 105 def compute_and_differentiate(_tdb, _tdb2 = 0.0) raise NotImplementedError, "#{self.class} has not implemented compute_and_differentiate() for data type #{@data_type}" end |
#describe(verbose: false) ⇒ String
Detailed description of the segment
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ephem/segments/base_segment.rb', line 81 def describe(verbose: false) start_date = format_date(*julian_to_gregorian(@start_jd)) end_date = format_date(*julian_to_gregorian(@end_jd)) center_name = get_body_name(@center, "Unknown Center") target_name = get_body_name(@target, "Unknown Target") dates = "#{start_date}..#{end_date}" center = "#{center_name} (#{@center})" target = "#{target_name} (#{@target})" description = "#{dates} Type #{@data_type} #{center} -> #{target}" return description unless verbose <<~DESCRIPTION.chomp #{description} frame=#{@frame} source=#{@source} DESCRIPTION end |
#to_s ⇒ String
String representation of the segment
73 74 75 |
# File 'lib/ephem/segments/base_segment.rb', line 73 def to_s describe(verbose: false) end |