Class: Puree::XMLExtractor::Resource
- Defined in:
- lib/puree/xml_extractor/resource.rb
Overview
Resource XML extractor.
Direct Known Subclasses
Dataset, Event, Journal, Organisation, Person, Project, Publication, Publisher
Instance Method Summary collapse
- #created ⇒ Time?
-
#get_data? ⇒ Boolean
Is there any data after get? For a response that provides a count of the results.
-
#initialize(xml:) ⇒ Resource
constructor
A new instance of Resource.
-
#locale ⇒ String?
Locale (e.g. en-GB).
- #modified ⇒ Time?
- #uuid ⇒ String?
-
#xpath_query(path) ⇒ Object
content based.
Methods inherited from Base
#xpath_query_for_multi_value, #xpath_query_for_single_value
Constructor Details
#initialize(xml:) ⇒ Resource
Returns a new instance of Resource.
9 10 11 |
# File 'lib/puree/xml_extractor/resource.rb', line 9 def initialize(xml:) super end |
Instance Method Details
#created ⇒ Time?
28 29 30 |
# File 'lib/puree/xml_extractor/resource.rb', line 28 def created Time.parse xpath_query_for_single_value('/created') end |
#get_data? ⇒ Boolean
Is there any data after get? For a response that provides a count of the results.
21 22 23 24 25 |
# File 'lib/puree/xml_extractor/resource.rb', line 21 def get_data? path = service_xpath_count xpath_result = @doc.xpath path xpath_result.text.strip === '1' ? true : false end |
#locale ⇒ String?
Locale (e.g. en-GB)
44 45 46 47 |
# File 'lib/puree/xml_extractor/resource.rb', line 44 def locale str = xpath_query_for_single_value '/@locale' str.tr('_','-') if str end |
#modified ⇒ Time?
33 34 35 |
# File 'lib/puree/xml_extractor/resource.rb', line 33 def modified Time.parse xpath_query_for_single_value('/modified') end |
#uuid ⇒ String?
38 39 40 |
# File 'lib/puree/xml_extractor/resource.rb', line 38 def uuid xpath_query_for_single_value '/@uuid' end |
#xpath_query(path) ⇒ Object
content based
14 15 16 17 |
# File 'lib/puree/xml_extractor/resource.rb', line 14 def xpath_query(path) path_from_root = service_xpath path @doc.xpath path_from_root end |