Class: LibTAD::Astronomy::AstronomyObject

Inherits:
Object
  • Object
show all
Defined in:
lib/types/astronomy/astronomy_object.rb

Overview

Astronomical information - sunrise and sunset times.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ AstronomyObject

Returns a new instance of AstronomyObject.



18
19
20
21
22
23
24
# File 'lib/types/astronomy/astronomy_object.rb', line 18

def initialize(hash)
  @name = hash.fetch('name', nil)
  @events = hash.fetch('events', nil)
    &.map { |e| AstronomyEvent.new(e) }

  @special = hash.dig('special', 'type')
end

Instance Attribute Details

#eventsArray<AstronomyEvent> (readonly)

Lists all sunrise/sunset events during the day.

Returns:



11
12
13
# File 'lib/types/astronomy/astronomy_object.rb', line 11

def events
  @events
end

#nameString (readonly)

Object name. Currently, the sun is the only supported astronomical object.

Returns:

  • (String)


7
8
9
# File 'lib/types/astronomy/astronomy_object.rb', line 7

def name
  @name
end

#specialString (readonly)

This element is only present if there are no astronomical events. In this case it will indicate if the sun is up or down the whole day.

Returns:

  • (String)


16
17
18
# File 'lib/types/astronomy/astronomy_object.rb', line 16

def special
  @special
end