Class: AIXM::Component::Timetable

Inherits:
Object
  • Object
show all
Defined in:
lib/aixm/component/timetable.rb

Overview

Note:

As of now, only predefined timetables (see CODES) are imlemented.

Timetables define activity time windows.

Cheat Sheat in Pseudo Code:

timetable = AIXM.timetable(
  code: String or Symbol
)
timetable.remarks = String or nil

Shortcuts:

  • AIXM::H24 - continuous, all day and all night

Constant Summary collapse

CODES =
{
  H24: :continuous,           # all day and all night
  HJ: :sunrise_to_sunset,     # all day
  HN: :sunset_to_sunrise,     # all night
  HX: :unspecified,
  HO: :operational_request,   # on request only
  NOTAM: :notam,              # see NOTAM
  OTHER: :other               # specify in remarks
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:) ⇒ Timetable


37
38
39
# File 'lib/aixm/component/timetable.rb', line 37

def initialize(code:)
  self.code = code
end

Instance Attribute Details

#codeSymbol


32
33
34
# File 'lib/aixm/component/timetable.rb', line 32

def code
  @code
end

#remarksString?


35
36
37
# File 'lib/aixm/component/timetable.rb', line 35

def remarks
  @remarks
end

Instance Method Details

#inspectString


42
43
44
# File 'lib/aixm/component/timetable.rb', line 42

def inspect
  %Q(#<#{self.class} code=#{code.inspect}>)
end

#to_xml(as: :Timetable) ⇒ String


55
56
57
58
59
60
61
# File 'lib/aixm/component/timetable.rb', line 55

def to_xml(as: :Timetable)
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.tag!(as) do |tag|
    tag.codeWorkHr(CODES.key(code).to_s)
    tag.txtRmkWorkHr(remarks) if remarks
  end
end