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::ENR54, 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) ⇒ AIXM::Feature
Add feature to AIXM.
- #borders ⇒ Object
- #cache ⇒ Object
- #close ⇒ Object
- #config ⇒ Object
-
#find(object) ⇒ Object
Find equal objects previously written to AIXM.
-
#find_by(klass, attributes = {}) ⇒ Object
Find objects of the given class and optionally with the given attribute values previously written to AIXM.
-
#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.
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" % [: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) ⇒ AIXM::Feature
Add feature to AIXM
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 |
#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 |
#find(object) ⇒ Object
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
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 |
#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
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
).
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 |