class AIXM::Feature::Unit
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)
@see gitlab.com/openflightmaps/ofmx/wikis/Organisation#uni-unit
Constants
- CLASSES
- TYPES
Attributes
name[R]
@return [String] name of unit (e.g. “MARSEILLE ACS”)
remarks[R]
@return [String, nil] free text remarks
type[R]
@return [Symbol] type of unit (see {TYPES})
Public Class Methods
new(source: nil, region: nil)
click to toggle source
# File lib/aixm/feature.rb 15 def initialize(source: nil, region: nil) 16 self.source = source 17 self.region = region || AIXM.config.region 18 end
new(source: nil, region: nil, organisation:, name:, type:, class:)
click to toggle source
Calls superclass method
AIXM::Feature::new
# File lib/aixm/feature/unit.rb 106 def initialize(source: nil, region: nil, organisation:, name:, type:, class:) 107 super(source: source, region: region) 108 self.organisation, self.name, self.type = organisation, name, type 109 self.class = binding.local_variable_get(:class) 110 end
Public Instance Methods
class()
click to toggle source
@!attribute class @note Use +Object#__class__+ alias to query the Ruby object class. @return [Symbol] class of unit (see {CLASSES})
# File lib/aixm/feature/unit.rb 129 def class 130 @klass 131 end
class=(value)
click to toggle source
# File lib/aixm/feature/unit.rb 133 def class=(value) 134 @klass = CLASSES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid class") 135 end
inspect()
click to toggle source
@return [String]
# File lib/aixm/feature/unit.rb 113 def inspect 114 %Q(#<#{__class__} name=#{name.inspect} type=#{type.inspect}>) 115 end
name=(value)
click to toggle source
# File lib/aixm/feature/unit.rb 117 def name=(value) 118 fail(ArgumentError, "invalid name") unless value.is_a? String 119 @name = value.uptrans 120 end
remarks=(value)
click to toggle source
# File lib/aixm/feature/unit.rb 137 def remarks=(value) 138 @remarks = value&.to_s 139 end
to_uid()
click to toggle source
@return [String] UID markup
# File lib/aixm/feature/unit.rb 142 def to_uid 143 builder = Builder::XmlMarkup.new(indent: 2) 144 builder.UniUid({ region: (region if AIXM.ofmx?) }.compact) do |uni_uid| 145 uni_uid.txtName(name) 146 uni_uid.codeType(TYPES.key(type).to_s) if AIXM.ofmx? 147 end 148 end
to_xml()
click to toggle source
@return [String] AIXM
or OFMX markup
# File lib/aixm/feature/unit.rb 152 def to_xml 153 builder = Builder::XmlMarkup.new(indent: 2) 154 builder.comment! "Unit: #{name_with_type}" 155 builder.Uni({ source: (source if AIXM.ofmx?) }.compact) do |uni| 156 uni << to_uid.indent(2) 157 uni << organisation.to_uid.indent(2) 158 uni << airport.to_uid.indent(2) if airport 159 uni.codeType(TYPES.key(type).to_s) unless AIXM.ofmx? 160 uni.codeClass(CLASSES.key(self.class).to_s) 161 uni.txtRmk(remarks) if remarks 162 end 163 services.sort { |a, b| a.type <=> b.type }.each do |service| 164 builder << service.to_xml 165 end 166 builder.target! 167 end
type=(value)
click to toggle source
# File lib/aixm/feature/unit.rb 122 def type=(value) 123 @type = TYPES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid type") 124 end
Private Instance Methods
name_with_type()
click to toggle source
# File lib/aixm/feature/unit.rb 171 def name_with_type 172 [name, TYPES.key(type)].join(' ') 173 end