Class: Tengai::Ephemeris
- Inherits:
-
Object
- Object
- Tengai::Ephemeris
- Includes:
- Virtus
- Defined in:
- lib/tengai/ephemeris.rb
Class Method Summary collapse
-
.fetch(client, body, options = {}) ⇒ Object
Public: fetch an ephemeris table for a given body using the client.
Instance Method Summary collapse
- #ephemeris_table=(table) ⇒ Object
-
#initialize(client, data) ⇒ Ephemeris
constructor
A new instance of Ephemeris.
- #target_body ⇒ Object
Constructor Details
#initialize(client, data) ⇒ Ephemeris
Returns a new instance of Ephemeris.
16 17 18 19 |
# File 'lib/tengai/ephemeris.rb', line 16 def initialize(client, data) super(data) @client = client end |
Class Method Details
.fetch(client, body, options = {}) ⇒ Object
Public: fetch an ephemeris table for a given body using the client
client - Tengai::Client body - a Tengai::Body instance whose ephemeris is needed options - A Hash of options for refining the ephemeris table
:start_time - The Time beginning of the ephemeris
:stop_time - The Time end of the ephemeris
:interval - The resolution of the table in minutes
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tengai/ephemeris.rb', line 37 def self.fetch(client, body, ={}) start_time = [:start_time] || Date.today.to_time # defaults start at today stop_time = [:stop_time] || (Date.today + 1).to_time # and end tomorrow interval = [:interval] || 1440 # Inject dependencies request = [:request] || EphemerisRequest parser = [:parser] || VectorEphemerisParser data = request.fetch( client, body.id, start_time: start_time, stop_time: stop_time, interval: interval) data = parser.parse(data) new(client, data) end |
Instance Method Details
#ephemeris_table=(table) ⇒ Object
25 26 27 |
# File 'lib/tengai/ephemeris.rb', line 25 def ephemeris_table=(table) @ephemeris_table = VectorEphemerisTable.new_with_table(table) end |
#target_body ⇒ Object
21 22 23 |
# File 'lib/tengai/ephemeris.rb', line 21 def target_body @target_body ||= Tengai::Body.find(@client, target_body_id) end |