Class: Hyrax::Ingest::Fetcher::XMLFile
- Includes:
- HasSIP
- Defined in:
- lib/hyrax/ingest/fetcher/xml_file.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#fetched_value ⇒ Object
readonly
Returns the value of attribute fetched_value.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#xpath ⇒ Object
readonly
Returns the value of attribute xpath.
Instance Method Summary collapse
-
#fetch ⇒ String
Overrides Hyrax::Ingest::Fetcher::Base#fetch.
-
#initialize(options = {}) ⇒ XMLFile
constructor
A new instance of XMLFile.
Methods included from HasSIP
Methods inherited from Base
Methods included from HasLogger
Methods included from HasReport
Constructor Details
#initialize(options = {}) ⇒ XMLFile
Returns a new instance of XMLFile.
17 18 19 20 21 22 23 24 |
# File 'lib/hyrax/ingest/fetcher/xml_file.rb', line 17 def initialize(={}) raise ArgumentError, "Required option :filename is missing" unless .key?(:filename) raise ArgumentError, "Required option :xpath is missing" unless .key?(:xpath) @filename = [:filename] @xpath = [:xpath] @default = [:default] || [] super end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
13 14 15 |
# File 'lib/hyrax/ingest/fetcher/xml_file.rb', line 13 def default @default end |
#fetched_value ⇒ Object (readonly)
Returns the value of attribute fetched_value.
13 14 15 |
# File 'lib/hyrax/ingest/fetcher/xml_file.rb', line 13 def fetched_value @fetched_value end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
13 14 15 |
# File 'lib/hyrax/ingest/fetcher/xml_file.rb', line 13 def filename @filename end |
#xpath ⇒ Object (readonly)
Returns the value of attribute xpath.
13 14 15 |
# File 'lib/hyrax/ingest/fetcher/xml_file.rb', line 13 def xpath @xpath end |
Instance Method Details
#fetch ⇒ String
Overrides Hyrax::Ingest::Fetcher::Base#fetch
28 29 30 31 32 33 |
# File 'lib/hyrax/ingest/fetcher/xml_file.rb', line 28 def fetch @fetched_value ||= begin fetched_from_xml = noko.xpath(xpath).map(&:text) fetched_from_xml.empty? ? default : fetched_from_xml end end |