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

  • AIXM::H_RE - pattern matching working hour codes

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

Returns a new instance of Timetable


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

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

Instance Attribute Details

#codeSymbol

Returns predefined timetable code (see CODES)

Returns:

  • (Symbol)

    predefined timetable code (see CODES)


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

def code
  @code
end

#remarksString?

Returns free text remarks

Returns:

  • (String, nil)

    free text remarks


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

def remarks
  @remarks
end

Instance Method Details

#inspectString

Returns:

  • (String)

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

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

#to_xml(as: :Timetable) ⇒ String

Returns AIXM or OFMX markup

Returns:

  • (String)

    AIXM or OFMX markup


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

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