Class: AIPP::AIP Abstract
Overview
Direct Known Subclasses
LF::AD13, LF::AD16, LF::AD2, LF::AD31, LF::ENR21, LF::ENR41, LF::ENR43, LF::ENR51, LF::ENR55
Constant Summary collapse
- DEPENDS =
[]
Instance Attribute Summary collapse
-
#aip ⇒ String
readonly
AIP name (e.g. “ENR-2.1”).
-
#fixture ⇒ Object
readonly
Fixture read from YAML file.
Instance Method Summary collapse
-
#add(feature) ⇒ Object
Add feature to AIXM.
- #borders ⇒ Object
- #cache ⇒ Object
- #close ⇒ Object
- #config ⇒ Object
-
#initialize(aip:, downloader:, fixture:, parser:) ⇒ AIP
constructor
A new instance of AIP.
- #options ⇒ Object
-
#read(aip_file = nil) ⇒ Nokogiri::HTML5::Document, String
Read an AIP source file.
-
#select(klass, attributes = {}) ⇒ Array<AIXM::Feature>
Search features previously written to AIXM and return those matching the given class and attribute values.
Methods included from Patcher
#attach_patches, #detach_patches
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" % [:region]).constantize end |
Instance Attribute Details
#aip ⇒ String (readonly)
Returns AIP name (e.g. “ENR-2.1”).
11 12 13 |
# File 'lib/aipp/aip.rb', line 11 def aip @aip end |
#fixture ⇒ Object (readonly)
Returns Fixture read from YAML file.
14 15 16 |
# File 'lib/aipp/aip.rb', line 14 def fixture @fixture end |
Instance Method Details
#add(feature) ⇒ Object
Add feature to AIXM
56 57 58 59 |
# File 'lib/aipp/aip.rb', line 56 def add(feature) verbose_info "Adding #{feature.inspect}" aixm.features << feature end |
#borders ⇒ Object
28 |
# File 'lib/aipp/aip.rb', line 28 def_delegators :@parser, :aixm, :config, :options, :borders, :cache |
#cache ⇒ Object
28 |
# File 'lib/aipp/aip.rb', line 28 def_delegators :@parser, :aixm, :config, :options, :borders, :cache |
#config ⇒ Object
28 |
# File 'lib/aipp/aip.rb', line 28 def_delegators :@parser, :aixm, :config, :options, :borders, :cache |
#options ⇒ Object
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
Depending on whether a local copy of the file exists, either:
-
download from URL to local storage and read from local archive
-
read from local archive
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
).
48 49 50 51 |
# File 'lib/aipp/aip.rb', line 48 def read(aip_file=nil) aip_file ||= aip @downloader.read(document: aip_file, url: url_for(aip_file)) end |
#select(klass, attributes = {}) ⇒ Array<AIXM::Feature>
Search features previously written to AIXM and return those matching the given class and attribute values
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/aipp/aip.rb', line 72 def select(klass, attributes={}) klass = AIXM::CLASSES.fetch(klass) if klass.is_a? Symbol aixm.features.select do |feature| if feature.is_a? klass attributes.reduce(true) do |memo, (attribute, value)| memo && feature.send(attribute) == value end end end end |