lib/aipp/regions/LF/AD-3.1.rb in aipp-0.2.5 vs lib/aipp/regions/LF/AD-3.1.rb in aipp-0.2.6
- old
+ new
@@ -24,11 +24,11 @@
def parse
prepare(html: read).css('tbody').each do |tbody|
tbody.css('tr').to_enum.each_slice(3).with_index(1) do |trs, index|
name = trs[0].css('span[id*="ADHP.TXT_NAME"]').text.cleanup.remove(/[^\w' ]/)
- if select(:airport, name: name).any?
+ if find_by(:airport, name: name).any?
verbose_info "Skipping #{name} in favor of AD-2"
next
end
# Airport
@airport = AIXM.airport(
@@ -40,24 +40,24 @@
).tap do |airport|
airport.z = elevation_from(trs[1].css('td:nth-of-type(2)').text)
end
# Usage restrictions
if trs[0].css('span[id*="ADHP.STATUT"]').text.match?(/usage\s+restreint/i)
- @airport.add_usage_limitation(:reservation_required) do |reservation_required|
+ @airport.add_usage_limitation(type: :reservation_required) do |reservation_required|
reservation_required.remarks = "Usage restreint / restricted use"
end
end
if trs[0].css('span[id*="ADHP.STATUT"]').text.match?(/r.serv.\s+aux\s+administrations/i)
- @airport.add_usage_limitation(:other) do |other|
+ @airport.add_usage_limitation(type: :other) do |other|
other.remarks = "Réservé aux administrations de l'État / reserved for State administrations"
end
end
# FATOs and helipads
text = trs[2].css('span[id*="ADHP.REVETEMENT"]').text.remove(/tlof\s*|\s*\(.*?\)/i).downcase.compact
surface = text.blank? ? {} : SURFACES.metch(text)
lighting = lighting_from(trs[1].css('span[id*="ADHP.BALISAGE"]').text.cleanup)
- fatos_from(trs[1].css('span[id*="ADHP.DIM_FATO"]').text).each { |f| @airport.add_fato f }
+ fatos_from(trs[1].css('span[id*="ADHP.DIM_FATO"]').text).each { @airport.add_fato(_1) }
helipads_from(trs[1].css('span[id*="ADHP.DIM_TLOF"]').text).each do |helipad|
helipad.surface.composition = surface[:composition]
helipad.surface.preparation = surface[:preparation]
helipad.surface.remarks = surface[:remarks]
helipad.surface.auw_weight = auw_weight_from(trs[2].css('span[id*="ADHP.RESISTANCE"]').text)
@@ -67,11 +67,11 @@
# Operator and addresses
operator = trs[0].css('span[id*="ADHP.EXPLOITANT"]')
splitted = operator.text.split(/( (?<!\p{L})t[ée]l | fax | standard | [\d\s]{10,} | \.\s | \( )/ix, 2)
@airport.operator = splitted[0].full_strip.truncate(60, omission: '…').blank_to_nil
raw_addresses = splitted[1..].join.cleanup.full_strip
- addresses_from(splitted[1..].join, source(position: operator.first.line)).each { |a| @airport.add_address(a) }
+ addresses_from(splitted[1..].join, source(position: operator.first.line)).each { @airport.add_address(_1) }
# Remarks
@airport.remarks = [].tap do |remarks|
hostility = trs[2].css('span[id*="ADHP.ZONE_HABITEE"]').text.cleanup.downcase.blank_to_nil
hostility = HOSTILITIES.fetch(hostility) if hostility
positioning = trs[2].css('span[id*="ADHP.EN_TERRASSE"]').text.cleanup.downcase.blank_to_nil
@@ -107,10 +107,10 @@
end
].compact
end
def dimensions_from(text)
- dims = text.remove(/[^x\d.,]/i).split(/x/i).map { |s| s.to_ff.floor }
+ dims = text.remove(/[^x\d.,]/i).split(/x/i).map { _1.to_ff.floor }
case dims.size
when 1
[dim = AIXM.d(dims[0], :m), dim]
when 2
[AIXM.d(dims[0], :m), AIXM.d(dims[1], :m)]