Class: AIXM::Feature::Organisation

Inherits:
AIXM::Feature show all
Defined in:
lib/aixm/feature/organisation.rb

Overview

Organisations and authorities such as ATS organisations, aircraft operating agencies, states and so forth.

Cheat Sheet in Pseudo Code:

organisation = AIXM.organisation(
  source: String or nil
  name: String
  type: TYPES
)
organisation.id = String or nil
organisation.remarks = String or nil

Constant Summary collapse

TYPES =
{
  S: :state,
  GS: :group_of_states,
  O: :national_organisation,
  IO: :international_organisation,
  AOA: :aircraft_operating_agency,
  ATS: :air_traffic_services_provider,
  HA: :handling_authority,
  A: :national_authority,
  OTHER: :other                          # specify in remarks
}.freeze

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature

#source

Instance Method Summary collapse

Methods inherited from AIXM::Feature

#==

Constructor Details

#initialize(source: nil, name:, type:) ⇒ Organisation

Returns a new instance of Organisation


46
47
48
49
# File 'lib/aixm/feature/organisation.rb', line 46

def initialize(source: nil, name:, type:)
  super(source: source)
  self.name, self.type = name, type
end

Instance Attribute Details

#idString?

Returns code of the organisation (e.g. “LF”)

Returns:

  • (String, nil)

    code of the organisation (e.g. “LF”)


41
42
43
# File 'lib/aixm/feature/organisation.rb', line 41

def id
  @id
end

#nameString

Returns name of organisation (e.g. “FRANCE”)

Returns:

  • (String)

    name of organisation (e.g. “FRANCE”)


35
36
37
# File 'lib/aixm/feature/organisation.rb', line 35

def name
  @name
end

#remarksString?

Returns free text remarks

Returns:

  • (String, nil)

    free text remarks


44
45
46
# File 'lib/aixm/feature/organisation.rb', line 44

def remarks
  @remarks
end

#typeSymbol

Returns type of organisation (see TYPES)

Returns:

  • (Symbol)

    type of organisation (see TYPES)


38
39
40
# File 'lib/aixm/feature/organisation.rb', line 38

def type
  @type
end

Instance Method Details

#inspectString

Returns:

  • (String)

52
53
54
# File 'lib/aixm/feature/organisation.rb', line 52

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

#to_uidString

Returns UID markup

Returns:

  • (String)

    UID markup


75
76
77
78
79
80
# File 'lib/aixm/feature/organisation.rb', line 75

def to_uid
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.OrgUid do |org_uid|
    org_uid.txtName(name)
  end
end

#to_xmlString

Returns AIXM or OFMX markup

Returns:

  • (String)

    AIXM or OFMX markup


83
84
85
86
87
88
89
90
91
92
# File 'lib/aixm/feature/organisation.rb', line 83

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.comment! "Organisation: #{name}"
  builder.Org({ source: (source if AIXM.ofmx?) }.compact) do |org|
    org << to_uid.indent(2)
    org.codeId(id) if id
    org.codeType(TYPES.key(type).to_s)
    org.txtRmk(remarks) if remarks
  end
end