Class: Solr::Response::Xml
Direct Known Subclasses
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#status_message ⇒ Object
readonly
Returns the value of attribute status_message.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(xml) ⇒ Xml
constructor
A new instance of Xml.
- #ok? ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(xml) ⇒ Xml
Returns a new instance of Xml.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/solr/response/xml.rb', line 19 def initialize(xml) super # parse the xml @doc = REXML::Document.new(xml) # look for the result code and string # <?xml version="1.0" encoding="UTF-8"?> # <response> # <lst name="responseHeader"><int name="status">0</int><int name="QTime">2</int></lst> # </response> result = REXML::XPath.first(@doc, './response/lst[@name="responseHeader"]/int[@name="status"]') if result @status_code = result.text @status_message = result.text # TODO: any need for a message? end rescue REXML::ParseException => e raise Solr::Exception.new("invalid response xml: #{e}") end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
17 18 19 |
# File 'lib/solr/response/xml.rb', line 17 def doc @doc end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
17 18 19 |
# File 'lib/solr/response/xml.rb', line 17 def status_code @status_code end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
17 18 19 |
# File 'lib/solr/response/xml.rb', line 17 def @status_message end |
Instance Method Details
#ok? ⇒ Boolean
38 39 40 |
# File 'lib/solr/response/xml.rb', line 38 def ok? return @status_code == '0' end |