Class: AIXM::Feature::Unit
- Inherits:
-
AIXM::Feature
- Object
- AIXM::Feature
- AIXM::Feature::Unit
- Includes:
- Association, Memoize
- Defined in:
- lib/aixm/feature/unit.rb
Overview
Units providing all kind of services such as air traffic management, search and rescue, meteorological services and so forth.
Cheat Sheet in Pseudo Code:
unit = AIXM.unit(
source: String or nil
region: String or nil
organisation: AIXM.organisation
name: String
type: TYPES
class: :icao or :other
)
unit.airport = AIXM.airport or nil
unit.remarks = String or nil
unit.add_service(AIXM.service)
Constant Summary collapse
- TYPES =
{ ACC: :area_control_centre, ADSU: :automatic_dependent_surveillance_unit, ADVC: :advisory_centre, ALPS: :alerting_post, AOF: :aeronautical_information_services_office, APP: :approach_control_office, 'APP-ARR': :arrivals_approach_control_office, 'APP-DEP': :depatures_approach_control_office, ARO: :air_traffic_service_reporting_office, ARTCC: :air_route_traffic_control_centre, ATCC: :air_traffic_control_centre, ATFMU: :air_traffic_flow_management_unit, ATMU: :air_traffic_management_unit, ATSU: :air_traffic_services_unit, BOF: :briefing_office, BS: :commercial_broadcasting_station, COM: :communications_office, FCST: :forecasting_office, FIC: :flight_information_centre, FSS: :flight_service_station, GCA: :ground_controlled_approach_systems_office, MET: :meteorological_office, MIL: :military_station, MILOPS: :military_flight_operations_briefing_office, MWO: :meteorological_watch_office, NOF: :international_notam_office, OAC: :oceanic_control_centre, PAR: :precision_approach_radar_centre, RAD: :radar_office, RAFC: :regional_area_forecast_centre, RCC: :rescue_coordination_centre, RSC: :rescue_sub_centre, SAR: :search_and_rescue_centre, SMC: :surface_movement_control_office, SMR: :surface_movement_radar_office, SRA: :surveillance_radar_approach_centre, SSR: :secondary_surveillance_radar_centre, TAR: :terminal_area_surveillance_radar_centre, TRACON: :terminal_radar_approach_control, TWR: :aerodrome_control_tower, UAC: :upper_area_control_centre, UDF: :uhf_direction_finding_station, UIC: :upper_information_centre, VDF: :vdf_direction_finding_station, WAFC: :world_area_forecast_centre, OTHER: :other # specify in remarks }.freeze
- CLASSES =
{ ICAO: :icao, OTHER: :other # specify in remarks }.freeze
Constants inherited from AIXM::Feature
Instance Attribute Summary collapse
-
#class ⇒ Symbol
Class of unit (see CLASSES).
-
#name ⇒ String
Name of unit (e.g. “MARSEILLE ACS”).
-
#remarks ⇒ String?
Free text remarks.
-
#type ⇒ Symbol
Type of unit (see TYPES).
Attributes inherited from AIXM::Feature
Instance Method Summary collapse
- #add_service(service) ⇒ Object
-
#airport ⇒ AIXM::Feature::Airport?
Airport.
-
#initialize(source: nil, region: nil, organisation:, name:, type:, class:) ⇒ Unit
constructor
A new instance of Unit.
- #inspect ⇒ String
-
#organisation ⇒ AIXM::Feature::Organisation
Superior organisation.
-
#services ⇒ Array<AIXM::Component::Service>
Services provided by this unit.
-
#to_uid ⇒ String
UID markup.
-
#to_xml ⇒ String
AIXM or OFMX markup.
Methods included from Memoize
Methods included from Association
Methods inherited from AIXM::Feature
Constructor Details
#initialize(source: nil, region: nil, organisation:, name:, type:, class:) ⇒ Unit
Returns a new instance of Unit.
106 107 108 109 110 |
# File 'lib/aixm/feature/unit.rb', line 106 def initialize(source: nil, region: nil, organisation:, name:, type:, class:) super(source: source, region: region) self.organisation, self.name, self.type = organisation, name, type self.class = binding.local_variable_get(:class) end |
Instance Attribute Details
#class ⇒ Symbol
Note:
Use Object#__class__ alias to query the Ruby object class.
Returns class of unit (see CLASSES).
129 130 131 |
# File 'lib/aixm/feature/unit.rb', line 129 def class @klass end |
#name ⇒ String
Returns name of unit (e.g. “MARSEILLE ACS”).
98 99 100 |
# File 'lib/aixm/feature/unit.rb', line 98 def name @name end |
#remarks ⇒ String?
Returns free text remarks.
104 105 106 |
# File 'lib/aixm/feature/unit.rb', line 104 def remarks @remarks end |
#type ⇒ Symbol
Returns type of unit (see TYPES).
101 102 103 |
# File 'lib/aixm/feature/unit.rb', line 101 def type @type end |
Instance Method Details
#airport ⇒ AIXM::Feature::Airport?
Returns airport.
95 |
# File 'lib/aixm/feature/unit.rb', line 95 belongs_to :airport |
#inspect ⇒ String
113 114 115 |
# File 'lib/aixm/feature/unit.rb', line 113 def inspect %Q(#<#{__class__} name=#{name.inspect} type=#{type.inspect}>) end |
#organisation ⇒ AIXM::Feature::Organisation
Returns superior organisation.
91 |
# File 'lib/aixm/feature/unit.rb', line 91 belongs_to :organisation, as: :member |
#services ⇒ Array<AIXM::Component::Service>
Returns services provided by this unit.
87 |
# File 'lib/aixm/feature/unit.rb', line 87 has_many :services |
#to_uid ⇒ String
Returns UID markup.
142 143 144 145 146 147 148 |
# File 'lib/aixm/feature/unit.rb', line 142 def to_uid builder = Builder::XmlMarkup.new(indent: 2) builder.UniUid({ region: (region if AIXM.ofmx?) }.compact) do |uni_uid| uni_uid.txtName(name) uni_uid.codeType(TYPES.key(type).to_s) if AIXM.ofmx? end end |
#to_xml ⇒ String
Returns AIXM or OFMX markup.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/aixm/feature/unit.rb', line 152 def to_xml builder = Builder::XmlMarkup.new(indent: 2) builder.comment! "Unit: #{name_with_type}" builder.Uni({ source: (source if AIXM.ofmx?) }.compact) do |uni| uni << to_uid.indent(2) uni << organisation.to_uid.indent(2) uni << airport.to_uid.indent(2) if airport uni.codeType(TYPES.key(type).to_s) unless AIXM.ofmx? uni.codeClass(CLASSES.key(self.class).to_s) uni.txtRmk(remarks) if remarks end services.sort { |a, b| a.type <=> b.type }.each do |service| builder << service.to_xml end builder.target! end |