Class: Placemaker::XmlParser

Inherits:
Object
  • Object
show all
Defined in:
lib/placemaker/xml_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml_body) ⇒ XmlParser

Returns a new instance of XmlParser.



5
6
7
# File 'lib/placemaker/xml_parser.rb', line 5

def initialize(xml_body)
  @xml = Nokogiri::XML(xml_body)
end

Instance Method Details

#document_lengthObject

length in bytes of the document



20
21
22
# File 'lib/placemaker/xml_parser.rb', line 20

def document_length
  @xml.xpath('.//xmlns:documentLength').inner_text.to_i
end

#documentsObject

Returns a set of Placemaker::Document objects as containers for content location information



25
26
27
28
29
# File 'lib/placemaker/xml_parser.rb', line 25

def documents
  @xml.xpath('//xmlns:document', 'xmlns' => 'http://wherein.yahooapis.com/v1/schema').map do |d|
    Placemaker::Document.new(d)
  end
end

#processing_timeObject

time in seconds to process the document



10
11
12
# File 'lib/placemaker/xml_parser.rb', line 10

def processing_time
  @xml.xpath('.//xmlns:processingTime').inner_text.to_f
end

#versionObject

version of the software used to process the document



15
16
17
# File 'lib/placemaker/xml_parser.rb', line 15

def version
  @xml.xpath('.//xmlns:version').inner_text.strip
end