Class: Puree::XMLExtractor::Base
- Inherits:
-
Object
- Object
- Puree::XMLExtractor::Base
- Defined in:
- lib/puree/xml_extractor/base.rb
Overview
Base XML extractor.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(xml:) ⇒ Base
constructor
A new instance of Base.
-
#xpath_query_for_multi_value(path) ⇒ Array<String>
XPath search for multiple values, at a given path.
-
#xpath_query_for_single_value(path) ⇒ String?
XPath search for a single value, at a given path.
Constructor Details
Instance Method Details
#xpath_query_for_multi_value(path) ⇒ Array<String>
XPath search for multiple values, at a given path.
25 26 27 28 29 30 |
# File 'lib/puree/xml_extractor/base.rb', line 25 def xpath_query_for_multi_value(path) xpath_result = xpath_query path arr = [] xpath_result.each { |i| arr << i.text.strip } arr.uniq end |
#xpath_query_for_single_value(path) ⇒ String?
XPath search for a single value, at a given path.
17 18 19 20 |
# File 'lib/puree/xml_extractor/base.rb', line 17 def xpath_query_for_single_value(path) xpath_result = xpath_query(path).text.strip xpath_result.empty? ? nil : xpath_result end |