Class: Placemaker::XmlParser
- Inherits:
-
Object
- Object
- Placemaker::XmlParser
- Defined in:
- lib/placemaker/xml_parser.rb
Instance Method Summary collapse
-
#document_length ⇒ Object
length in bytes of the document.
-
#documents ⇒ Object
Returns a set of Placemaker::Document objects as containers for content location information.
-
#initialize(xml_body) ⇒ XmlParser
constructor
A new instance of XmlParser.
-
#processing_time ⇒ Object
time in seconds to process the document.
-
#version ⇒ Object
version of the software used to process the document.
Constructor Details
#initialize(xml_body) ⇒ XmlParser
Returns a new instance of XmlParser.
3 4 5 6 |
# File 'lib/placemaker/xml_parser.rb', line 3 def initialize(xml_body) @body = xml_body @xml = Nokogiri::XML(xml_body) end |
Instance Method Details
#document_length ⇒ Object
length in bytes of the document
19 20 21 |
# File 'lib/placemaker/xml_parser.rb', line 19 def document_length @xml.xpath('.//xmlns:documentLength', 'xmlns' => 'http://wherein.yahooapis.com/v1/schema').inner_text.to_i end |
#documents ⇒ Object
Returns a set of Placemaker::Document objects as containers for content location information
24 25 26 27 28 |
# File 'lib/placemaker/xml_parser.rb', line 24 def documents @xml.xpath('//xmlns:document', 'xmlns' => 'http://wherein.yahooapis.com/v1/schema').map do |d| Placemaker::Document.new(d) end end |
#processing_time ⇒ Object
time in seconds to process the document
9 10 11 |
# File 'lib/placemaker/xml_parser.rb', line 9 def processing_time @xml.xpath('.//xmlns:processingTime', 'xmlns' => 'http://wherein.yahooapis.com/v1/schema').inner_text.to_f end |
#version ⇒ Object
version of the software used to process the document
14 15 16 |
# File 'lib/placemaker/xml_parser.rb', line 14 def version @xml.xpath('.//xmlns:version', 'xmlns' => 'http://wherein.yahooapis.com/v1/schema').inner_text.strip end |