Class: AIXM::Feature::Organisation

Inherits:
AIXM::Feature show all
Includes:
Association, Memoize
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
  region: 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

Constants inherited from AIXM::Feature

REGION_RE

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature

#region, #source

Instance Method Summary collapse

Methods included from Memoize

cache, included, method

Methods included from Association

included

Methods inherited from AIXM::Feature

#==

Constructor Details

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

Returns a new instance of Organisation.


61
62
63
64
# File 'lib/aixm/feature/organisation.rb', line 61

def initialize(source: nil, region: nil, name:, type:)
  super(source: source, region: region)
  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”)


56
57
58
# File 'lib/aixm/feature/organisation.rb', line 56

def id
  @id
end

#nameString

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

Returns:

  • (String)

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


50
51
52
# File 'lib/aixm/feature/organisation.rb', line 50

def name
  @name
end

#remarksString?

Returns free text remarks.

Returns:

  • (String, nil)

    free text remarks


59
60
61
# File 'lib/aixm/feature/organisation.rb', line 59

def remarks
  @remarks
end

#typeSymbol

Returns type of organisation (see TYPES).

Returns:

  • (Symbol)

    type of organisation (see TYPES)


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

def type
  @type
end

Instance Method Details

#add_member(member) ⇒ self


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

has_many :members, accept: [:airport, :unit, 'AIXM::Feature::NavigationalAid']

#inspectString

Returns:

  • (String)

67
68
69
# File 'lib/aixm/feature/organisation.rb', line 67

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

#membersArray<AIXM::Feature::Airport, AIXM::Feature::Unit, AIXM::Feature::NavigationalAid>

Returns aiports, units or navigational aids.

Returns:


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

has_many :members, accept: [:airport, :unit, 'AIXM::Feature::NavigationalAid']

#to_uidString

Returns UID markup.

Returns:

  • (String)

    UID markup


90
91
92
93
94
95
# File 'lib/aixm/feature/organisation.rb', line 90

def to_uid
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.OrgUid({ region: (region if AIXM.ofmx?) }.compact) do |org_uid|
    org_uid.txtName(name)
  end
end

#to_xmlString

Returns AIXM or OFMX markup.

Returns:

  • (String)

    AIXM or OFMX markup


99
100
101
102
103
104
105
106
107
108
# File 'lib/aixm/feature/organisation.rb', line 99

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