Class: AIPP::LF::ENR41

Inherits:
AIP show all
Includes:
Helpers::Common
Defined in:
lib/aipp/regions/LF/ENR-4.1.rb

Overview

ENR Navaids

Constant Summary

Constants included from Helpers::Common

Helpers::Common::ANGLICISE_MAP, Helpers::Common::BORDERS, Helpers::Common::INTERSECTIONS, Helpers::Common::SURFACES

Constants inherited from AIP

AIP::DEPENDS

Instance Attribute Summary

Attributes inherited from AIP

#aip, #fixture

Instance Method Summary collapse

Methods included from Helpers::Common

#anglicise, #elevation_from, #geometry_from, #layer_from, #organisation_lf, #prepare, #source, #timetable_from!, #xy_from

Methods inherited from AIP

#add, #borders, #cache, #close, #config, #initialize, #options, #read, #select

Methods included from Patcher

#attach_patches, #detach_patches

Constructor Details

This class inherits a constructor from AIPP::AIP

Instance Method Details

#parseObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/aipp/regions/LF/ENR-4.1.rb', line 9

def parse
  prepare(html: read).css('tbody').each do |tbody|
    tbody.css('tr').to_enum.with_index(1).each do |tr, index|
      tds = tr.css('td')
      master, slave = tds[1].text.strip.gsub(/[^\w-]/, '').downcase.split('-')
      navaid = AIXM.send(master, base_from(tds).merge(send("#{master}_from", tds)))
      navaid.source = source(position: tr.line)
      navaid.timetable = timetable_from! tds[4].text
      navaid.remarks = remarks_from(tds[5], tds[7], tds[9])
      navaid.send("associate_#{slave}", channel: channel_from(tds[3].text)) if slave
      add navaid
    rescue => error
      warn("error parsing navigational aid at ##{index}: #{error.message}", pry: error)
    end
  end
end