Class: Astronoby::LocalSiderealTime

Inherits:
Object
  • Object
show all
Defined in:
lib/astronoby/time/local_sidereal_time.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date:, time:, longitude:) ⇒ LocalSiderealTime

Returns a new instance of LocalSiderealTime.



21
22
23
24
25
# File 'lib/astronoby/time/local_sidereal_time.rb', line 21

def initialize(date:, time:, longitude:)
  @date = date
  @time = time
  @longitude = longitude
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



5
6
7
# File 'lib/astronoby/time/local_sidereal_time.rb', line 5

def date
  @date
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



5
6
7
# File 'lib/astronoby/time/local_sidereal_time.rb', line 5

def longitude
  @longitude
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/astronoby/time/local_sidereal_time.rb', line 5

def time
  @time
end

Class Method Details

.from_gst(gst:, longitude:) ⇒ Object

Source:

Title: Practical Astronomy with your Calculator or Spreadsheet
Authors: Peter Duffett-Smith and Jonathan Zwart
Edition: Cambridge University Press
Chapter: 14 - Local sidereal time (LST)


12
13
14
15
16
17
18
19
# File 'lib/astronoby/time/local_sidereal_time.rb', line 12

def self.from_gst(gst:, longitude:)
  date = gst.date
  time = gst.time + longitude.hours
  time += Constants::HOURS_PER_DAY if time.negative?
  time -= Constants::HOURS_PER_DAY if time > Constants::HOURS_PER_DAY

  new(date: date, time: time, longitude: longitude)
end

Instance Method Details

#to_gstObject

Source:

Title: Practical Astronomy with your Calculator or Spreadsheet
Authors: Peter Duffett-Smith and Jonathan Zwart
Edition: Cambridge University Press
Chapter: 15 - Converting LST to GST


32
33
34
35
36
37
38
39
# File 'lib/astronoby/time/local_sidereal_time.rb', line 32

def to_gst
  date = @date
  time = @time - @longitude.hours
  time += Constants::HOURS_PER_DAY if time.negative?
  time -= Constants::HOURS_PER_DAY if time > Constants::HOURS_PER_DAY

  GreenwichSiderealTime.new(date: date, time: time)
end