Class: AIXM::Component::FATO::Direction

Inherits:
Object
  • Object
show all
Defined in:
lib/aixm/component/fato.rb

Overview

FATO directions further describe each direction to and from the FATO.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fato:, name:) ⇒ Direction


180
181
182
183
# File 'lib/aixm/component/fato.rb', line 180

def initialize(fato:, name:)
  self.fato, self.name = fato, name
  @lightings = []
end

Instance Attribute Details

#fato=(value) ⇒ Object


190
191
192
193
# File 'lib/aixm/component/fato.rb', line 190

def fato=(value)
  fail(ArgumentError, "invalid FATO") unless value.is_a? AIXM::Component::FATO
  @fato = value
end

#geographic_orientationAIXM::A?


172
173
174
# File 'lib/aixm/component/fato.rb', line 172

def geographic_orientation
  @geographic_orientation
end

#lightingsArray<AIXM::Component::Lighting> (readonly)


178
179
180
# File 'lib/aixm/component/fato.rb', line 178

def lightings
  @lightings
end

#nameAIXM::A


169
170
171
# File 'lib/aixm/component/fato.rb', line 169

def name
  @name
end

#remarksString?


175
176
177
# File 'lib/aixm/component/fato.rb', line 175

def remarks
  @remarks
end

Instance Method Details

#add_lighting(lighting) ⇒ self

Add a lighting system to the FATO direction.


215
216
217
218
219
220
# File 'lib/aixm/component/fato.rb', line 215

def add_lighting(lighting)
  fail(ArgumentError, "invalid lighting") unless lighting.is_a? AIXM::Component::Lighting
  lighting.send(:lightable=, self)
  @lightings << lighting
  self
end

#inspectString


186
187
188
# File 'lib/aixm/component/fato.rb', line 186

def inspect
  %Q(#<#{self.class} airport=#{fato&.airport&.id.inspect} name=#{name.inspect}>)
end

#magnetic_orientationAIXM::A


223
224
225
226
227
# File 'lib/aixm/component/fato.rb', line 223

def magnetic_orientation
  if geographic_orientation && fato.airport.declination
    geographic_orientation - fato.airport.declination
  end
end

#to_uidString


230
231
232
233
234
235
236
# File 'lib/aixm/component/fato.rb', line 230

def to_uid
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.FdnUid do |fdn_uid|
    fdn_uid << fato.to_uid.indent(2)
    fdn_uid.txtDesig(name)
  end.insert_payload_hash(region: AIXM.config.mid_region)
end

#to_xmlString


239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/aixm/component/fato.rb', line 239

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.Fdn do |fdn|
    fdn << to_uid.indent(2)
    fdn.valTrueBrg(geographic_orientation) if geographic_orientation
    fdn.valMagBrg(magnetic_orientation) if magnetic_orientation
    fdn.txtRmk(remarks) if remarks
  end
  lightings.each do |lighting|
    builder << lighting.to_xml(as: :Fls)
  end
  builder.target!
end