Class: LibTAD::Astronomy::AstronomyObject
- Inherits:
-
Object
- Object
- LibTAD::Astronomy::AstronomyObject
- Defined in:
- lib/types/astronomy/astronomy_object.rb
Overview
Astronomical information - sunrise and sunset times.
Instance Attribute Summary collapse
-
#events ⇒ Array<AstronomyEvent>
readonly
Lists all sunrise/sunset events during the day.
-
#name ⇒ String
readonly
Object name.
-
#special ⇒ String
readonly
This element is only present if there are no astronomical events.
Instance Method Summary collapse
-
#initialize(hash) ⇒ AstronomyObject
constructor
A new instance of AstronomyObject.
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
#events ⇒ Array<AstronomyEvent> (readonly)
Lists all sunrise/sunset events during the day.
11 12 13 |
# File 'lib/types/astronomy/astronomy_object.rb', line 11 def events @events end |
#name ⇒ String (readonly)
Object name. Currently, the sun is the only supported astronomical object.
7 8 9 |
# File 'lib/types/astronomy/astronomy_object.rb', line 7 def name @name end |
#special ⇒ String (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.
16 17 18 |
# File 'lib/types/astronomy/astronomy_object.rb', line 16 def special @special end |