Class: NOTAM::D

Inherits:
Item
  • Object
show all
Defined in:
lib/notam/item/d.rb

Overview

The D item contains timesheets to further narrow when exactly the NOTAM is effective.

Constant Summary

Constants inherited from Item

Item::ICAO_RE, Item::ID_RE, Item::RE, Item::TIME_RE

Instance Attribute Summary collapse

Attributes inherited from Item

#captures, #data, #text

Instance Method Summary collapse

Methods inherited from Item

#fail!, #initialize, #inspect, type, #type

Constructor Details

This class inherits a constructor from NOTAM::Item

Instance Attribute Details

#schedulesArray<NOTAM::Schedule> (readonly)

Activity schedules

Returns:



12
13
14
# File 'lib/notam/item/d.rb', line 12

def schedules
  @schedules
end

Instance Method Details

#active?(at:) ⇒ Boolean

Whether the D item is active at the given time.

Parameters:

  • at (Time)

Returns:

  • (Boolean)


31
32
33
# File 'lib/notam/item/d.rb', line 31

def active?(at:)
  schedules.any? { _1.active?(at: at, xy: data[:center_point]) }
end

#five_day_schedulesArray<NOTAM::Schedule>

Calculate the relevant, consolidated schedules for five days.

The beginning of the five day window is either today (if effective_at is in the past) or effective_at (otherwise).

Returns:



41
42
43
44
45
46
47
# File 'lib/notam/item/d.rb', line 41

def five_day_schedules
  schedules.map do |schedule|
    schedule
      .slice(AIXM.date(five_day_base), AIXM.date(five_day_base + 4 * 86_400))
      .resolve(on: AIXM.date(five_day_base), xy: data[:center_point])
  end.map { _1 unless _1.empty? }.compact
end

#mergeObject

See Also:



50
51
52
# File 'lib/notam/item/d.rb', line 50

def merge
  super(:schedules, :five_day_schedules)
end

#parseObject

See Also:



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/notam/item/d.rb', line 15

def parse
  base_date = AIXM.date(data[:effective_at])
  @schedules = text.sub(/\AD\)/, '').split(',').flat_map do |string|
    Schedule.parse(string, base_date: base_date).tap do |schedule|
      base_date = schedule.last.last_date || base_date   # carry over month
    end
  end
  self
rescue
  fail! 'invalid D item'
end