36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/xtf/result/element/base.rb', line 36
def parse_xml(xml, query)
@xml = xml.to_s.gsub(/\s+/, " ").strip
@query = query
@doc = XML::Document.parse_string(xml).root
doc_hit = @doc.at('//docHit')
meta = doc_hit.at('//meta')
@rank = doc_hit['rank']
@path = @raw_path = doc_hit['path']
@score = doc_hit['score']
@meta_hit_count = doc_hit.search('//meta//hit').size rescue 0
@total_hits = doc_hit['totalHits'].to_i > 0 ? doc_hit['totalHits'] : @meta_hit_count.to_s
end
|