Class: AIPP::AIP Abstract

Inherits:
Object show all
Extended by:
Forwardable
Includes:
Patcher
Defined in:
lib/aipp/aip.rb

Overview

This class is abstract.

Constant Summary collapse

DEPENDS =
[]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Patcher

#attach_patches, #detach_patches, included

Constructor Details

#initialize(aip:, downloader:, fixture:, parser:) ⇒ AIP

Returns a new instance of AIP.


31
32
33
34
# File 'lib/aipp/aip.rb', line 31

def initialize(aip:, downloader:, fixture:, parser:)
  @aip, @downloader, @fixture, @parser = aip, downloader, fixture, parser
  self.class.include ("AIPP::%s::Helpers::URL" % options[:region]).constantize
end

Instance Attribute Details

#aipString (readonly)

Returns AIP name (e.g. “ENR-2.1”).

Returns:

  • (String)

    AIP name (e.g. “ENR-2.1”)


11
12
13
# File 'lib/aipp/aip.rb', line 11

def aip
  @aip
end

#fixtureObject (readonly)

Returns Fixture read from YAML file.

Returns:

  • (Object)

    Fixture read from YAML file


14
15
16
# File 'lib/aipp/aip.rb', line 14

def fixture
  @fixture
end

Instance Method Details

#add(feature) ⇒ AIXM::Feature

Add feature to AIXM

Parameters:

  • feature (AIXM::Feature)

    e.g. airport or airspace

Returns:

  • (AIXM::Feature)

    added feature


56
57
58
59
60
# File 'lib/aipp/aip.rb', line 56

def add(feature)
  verbose_info "Adding #{feature.inspect}"
  aixm.add_feature feature
  feature
end

#bordersObject

See Also:


28
# File 'lib/aipp/aip.rb', line 28

def_delegators :@parser, :aixm, :config, :options, :borders, :cache

#cacheObject

See Also:


28
# File 'lib/aipp/aip.rb', line 28

def_delegators :@parser, :aixm, :config, :options, :borders, :cache

#closeObject

See Also:

  • Downloader#close

18
# File 'lib/aipp/aip.rb', line 18

def_delegator :@downloader, :close

#configObject

See Also:


28
# File 'lib/aipp/aip.rb', line 28

def_delegators :@parser, :aixm, :config, :options, :borders, :cache

#find(object) ⇒ Object

Note:

This method is delegated to AIXM::Association::Array.

Find equal objects previously written to AIXM.


74
75
76
77
78
# File 'lib/aipp/aip.rb', line 74

%i(find_by find).each do |method|
  define_method method do |*args|
    aixm.features.send(method, *args)
  end
end

#find_by(klass, attributes = {}) ⇒ Object

Note:

This method is delegated to AIXM::Association::Array.

Find objects of the given class and optionally with the given attribute values previously written to AIXM.


74
75
76
77
78
# File 'lib/aipp/aip.rb', line 74

%i(find_by find).each do |method|
  define_method method do |*args|
    aixm.features.send(method, *args)
  end
end

#optionsObject

See Also:


28
# File 'lib/aipp/aip.rb', line 28

def_delegators :@parser, :aixm, :config, :options, :borders, :cache

#read(aip_file = nil) ⇒ Nokogiri::HTML5::Document, String

Read an AIP source file

Read the cached source file if it exists in the source archive. Otherwise, download it from URL and cache it.

An URL builder method url_for(aip_file) must be defined either in helper.rb or in the AIP parser definition (e.g. ENR-2.1.rb).

Parameters:

  • aip_file (String) (defaults to: nil)

    e.g. “ENR-2.1” or “AD-2.LFMV” (default: aip)

Returns:

  • (Nokogiri::HTML5::Document, String)

    HTML as Nokogiri document, PDF or TXT as String


47
48
49
50
# File 'lib/aipp/aip.rb', line 47

def read(aip_file=nil)
  aip_file ||= aip
  @downloader.read(document: aip_file, url: url_for(aip_file))
end