Class: Astronoby::Conjunction

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

Constant Summary collapse

INFERIOR =
:inferior
SUPERIOR =
:superior

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instant:, body:, subtype:) ⇒ Conjunction

Returns a new instance of Conjunction.

Parameters:

  • instant (Astronoby::Instant)

    when the conjunction occurs

  • body (Astronoby::Body)

    the body in conjunction with the Sun

  • subtype (Symbol)

    INFERIOR or SUPERIOR



34
35
36
37
38
39
# File 'lib/astronoby/events/conjunction.rb', line 34

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

Instance Attribute Details

#bodyAstronoby::Body (readonly)

Returns the body in conjunction with the Sun.

Returns:



26
27
28
# File 'lib/astronoby/events/conjunction.rb', line 26

def body
  @body
end

#instantAstronoby::Instant (readonly)

Returns when the conjunction occurs.

Returns:



23
24
25
# File 'lib/astronoby/events/conjunction.rb', line 23

def instant
  @instant
end

#subtypeSymbol (readonly)

Returns INFERIOR or SUPERIOR.

Returns:

  • (Symbol)

    INFERIOR or SUPERIOR



29
30
31
# File 'lib/astronoby/events/conjunction.rb', line 29

def subtype
  @subtype
end

Class Method Details

.inferior(instant:, body:) ⇒ Astronoby::Conjunction

Returns an inferior conjunction.

Parameters:

Returns:



11
12
13
# File 'lib/astronoby/events/conjunction.rb', line 11

def self.inferior(instant:, body:)
  new(instant: instant, body: body, subtype: INFERIOR)
end

.superior(instant:, body:) ⇒ Astronoby::Conjunction

Returns a superior conjunction.

Parameters:

Returns:



18
19
20
# File 'lib/astronoby/events/conjunction.rb', line 18

def self.superior(instant:, body:)
  new(instant: instant, body: body, subtype: SUPERIOR)
end

Instance Method Details

#inferior?Boolean

Returns true for an inferior conjunction.

Returns:

  • (Boolean)

    true for an inferior conjunction



42
43
44
# File 'lib/astronoby/events/conjunction.rb', line 42

def inferior?
  @subtype == INFERIOR
end

#superior?Boolean

Returns true for a superior conjunction.

Returns:

  • (Boolean)

    true for a superior conjunction



47
48
49
# File 'lib/astronoby/events/conjunction.rb', line 47

def superior?
  @subtype == SUPERIOR
end