Class: Astronoby::GreatestElongation

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

Constant Summary collapse

EASTERN =
:eastern
WESTERN =
:western

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instant:, body:, angle:, direction:) ⇒ GreatestElongation

Returns a new instance of GreatestElongation.

Parameters:

  • instant (Astronoby::Instant)

    when the greatest elongation occurs

  • body (Astronoby::Body)

    the body reaching greatest elongation

  • angle (Astronoby::Angle)

    the Sun-Earth-body angle at that instant

  • direction (Symbol)

    EASTERN or WESTERN



40
41
42
43
44
45
46
# File 'lib/astronoby/events/greatest_elongation.rb', line 40

def initialize(instant:, body:, angle:, direction:)
  @instant = instant
  @body = body
  @angle = angle
  @direction = direction
  freeze
end

Instance Attribute Details

#angleAstronoby::Angle (readonly)

Returns the Sun-Earth-body angle at that instant.

Returns:



31
32
33
# File 'lib/astronoby/events/greatest_elongation.rb', line 31

def angle
  @angle
end

#bodyAstronoby::Body (readonly)

Returns the body reaching greatest elongation.

Returns:



28
29
30
# File 'lib/astronoby/events/greatest_elongation.rb', line 28

def body
  @body
end

#directionSymbol (readonly)

Returns EASTERN or WESTERN.

Returns:

  • (Symbol)

    EASTERN or WESTERN



34
35
36
# File 'lib/astronoby/events/greatest_elongation.rb', line 34

def direction
  @direction
end

#instantAstronoby::Instant (readonly)

Returns when the greatest elongation occurs.

Returns:



25
26
27
# File 'lib/astronoby/events/greatest_elongation.rb', line 25

def instant
  @instant
end

Class Method Details

.eastern(instant:, body:, angle:) ⇒ Astronoby::GreatestElongation

Returns a greatest eastern elongation.

Parameters:

Returns:



12
13
14
# File 'lib/astronoby/events/greatest_elongation.rb', line 12

def self.eastern(instant:, body:, angle:)
  new(instant: instant, body: body, angle: angle, direction: EASTERN)
end

.western(instant:, body:, angle:) ⇒ Astronoby::GreatestElongation

Returns a greatest western elongation.

Parameters:

Returns:



20
21
22
# File 'lib/astronoby/events/greatest_elongation.rb', line 20

def self.western(instant:, body:, angle:)
  new(instant: instant, body: body, angle: angle, direction: WESTERN)
end

Instance Method Details

#eastern?Boolean

Returns true for a greatest eastern elongation.

Returns:

  • (Boolean)

    true for a greatest eastern elongation



49
50
51
# File 'lib/astronoby/events/greatest_elongation.rb', line 49

def eastern?
  @direction == EASTERN
end

#western?Boolean

Returns true for a greatest western elongation.

Returns:

  • (Boolean)

    true for a greatest western elongation



54
55
56
# File 'lib/astronoby/events/greatest_elongation.rb', line 54

def western?
  @direction == WESTERN
end