class AIPP::LF::Helpers::NavigationalAid::NavigationalAid
Constants
- NAVIGATIONAL_AIDS
Map atypical navigational aid denominations
Public Class Methods
new(tds, source:, sections:)
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 22 def initialize(tds, source:, sections:) 23 @tds, @source, @sections = tds, source, sections 24 end
Public Instance Methods
build()
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 26 def build 27 master, slave = @tds[:type].text.strip.gsub(/[^\w-]/, '').downcase.split('-') 28 master = NAVIGATIONAL_AIDS.fetch(master, master) 29 slave = NAVIGATIONAL_AIDS.fetch(slave, slave) 30 return nil unless NAVIGATIONAL_AIDS.keys.include? master 31 AIXM.send(master, common.merge(send(master))).tap do |navigational_aid| 32 navigational_aid.source = @source 33 navigational_aid.remarks = remarks 34 navigational_aid.timetable = timetable_from!(@tds[:schedule].text) 35 navigational_aid.send("associate_#{slave}", channel: channel_from(@tds[:f].text)) if slave 36 end 37 end
Private Instance Methods
channel_from(text)
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 96 def channel_from(text) 97 parts = text.strip.split(/\s+/) 98 parts.last if parts[-2].downcase == 'ch' 99 end
common()
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 41 def common 42 { 43 organisation: organisation_lf, 44 id: @tds[:id].text.strip, 45 name: @tds[:name].text.strip, 46 xy: xy_from(@tds[:xy].text), 47 z: z_from(@tds[:z].text) 48 } 49 end
dme()
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 59 def dme 60 { 61 channel: channel_from(@tds[:f].text) 62 } 63 end
f_from(text)
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 91 def f_from(text) 92 parts = text.strip.split(/\s+/) 93 AIXM.f(parts[0].to_f, parts[1]) if parts[1] =~ /hz$/i 94 end
ndb()
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 65 def ndb 66 { 67 type: @tds[:type].text.strip == 'L' ? :locator : :en_route, 68 f: f_from(@tds[:f].text) 69 } 70 end
remarks()
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 78 def remarks 79 @sections.map do |section, td| 80 if text = td.text.strip.blank_to_nil 81 "**#{section.upcase}**\n#{text}" 82 end 83 end.compact.join("\n\n").blank_to_nil 84 end
tacan()
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 72 def tacan 73 { 74 channel: channel_from(@tds[:f].text) 75 } 76 end
vor()
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 51 def vor 52 { 53 type: :conventional, 54 f: f_from(@tds[:f].text), 55 north: :magnetic, 56 } 57 end
z_from(text)
click to toggle source
# File lib/aipp/regions/LF/helpers/navigational_aid.rb 86 def z_from(text) 87 parts = text.strip.split(/\s+/) 88 AIXM.z(parts[0].to_i, :qnh) if parts[1] == 'ft' 89 end