Class: Solr::Response::Xml
Overview
The ASF licenses this file to You under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/solr/response/xml.rb', line 16 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.
14 15 16 |
# File 'lib/solr/response/xml.rb', line 14 def doc @doc end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
14 15 16 |
# File 'lib/solr/response/xml.rb', line 14 def status_code @status_code end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
14 15 16 |
# File 'lib/solr/response/xml.rb', line 14 def @status_message end |
Instance Method Details
#ok? ⇒ Boolean
35 36 37 |
# File 'lib/solr/response/xml.rb', line 35 def ok? return @status_code == '0' end |