Class: Astronoby::Observer

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

Constant Summary collapse

DEFAULT_ELEVATION =
Distance.zero
DEFAULT_TEMPERATURE =
283.15
PRESSURE_AT_SEA_LEVEL =
1013.25
PASCAL_PER_MILLIBAR =
0.01
EARTH_GRAVITATIONAL_ACCELERATION =
9.80665
MOLAR_MASS_OF_AIR =
0.0289644
UNIVERSAL_GAS_CONSTANT =
8.31432

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latitude:, longitude:, elevation: DEFAULT_ELEVATION, temperature: DEFAULT_TEMPERATURE, pressure: nil) ⇒ Observer

Returns a new instance of Observer.

Parameters:

  • latitude (Angle)

    geographic latitude of the observer

  • longitude (Angle)

    geographic longitude of the observer

  • elevation (Astronoby::Distance) (defaults to: DEFAULT_ELEVATION)

    geographic elevation (or altitude) of the observer above sea level

  • temperature (Numeric) (defaults to: DEFAULT_TEMPERATURE)

    temperature at the observer’s location in kelvins

  • pressure (Numeric) (defaults to: nil)

    atmospheric pressure at the observer’s location in millibars



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/astronoby/observer.rb', line 23

def initialize(
  latitude:,
  longitude:,
  elevation: DEFAULT_ELEVATION,
  temperature: DEFAULT_TEMPERATURE,
  pressure: nil
)
  @latitude = latitude
  @longitude = longitude
  @elevation = elevation
  @temperature = temperature
  @pressure = pressure || compute_pressure
end

Instance Attribute Details

#elevationObject (readonly)

Returns the value of attribute elevation.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def elevation
  @elevation
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def latitude
  @latitude
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def longitude
  @longitude
end

#pressureObject (readonly)

Returns the value of attribute pressure.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def pressure
  @pressure
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



13
14
15
# File 'lib/astronoby/observer.rb', line 13

def temperature
  @temperature
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



37
38
39
40
41
42
43
44
45
# File 'lib/astronoby/observer.rb', line 37

def ==(other)
  return false unless other.is_a?(self.class)

  @latitude == other.latitude &&
    @longitude == other.longitude &&
    @elevation == other.elevation &&
    @temperature == other.temperature &&
    @pressure == other.pressure
end

#hashObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/astronoby/observer.rb', line 48

def hash
  [
    self.class,
    @latitude,
    @longitude,
    @elevation,
    @temperature,
    @pressure
  ].hash
end