Class: OAI::Response
- Inherits:
-
Object
- Object
- OAI::Response
- Includes:
- XPath
- Defined in:
- lib/oai/client/response.rb
Direct Known Subclasses
GetRecordResponse, IdentifyResponse, ListIdentifiersResponse, ListMetadataFormatsResponse, ListRecordsResponse, ListSetsResponse
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#resumption_token ⇒ Object
readonly
Returns the value of attribute resumption_token.
Instance Method Summary collapse
-
#initialize(doc) ⇒ Response
constructor
A new instance of Response.
Methods included from XPath
#get_attribute, #xpath, #xpath_all, #xpath_first
Constructor Details
#initialize(doc) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/oai/client/response.rb', line 6 def initialize(doc) @doc = doc @resumption_token = xpath(doc, './/resumptionToken') # throw an exception if there was an error error = xpath_first(doc, './/error') return unless error case error.class.to_s when 'REXML::Element' = error.text code = error.attributes['code'] when 'LibXML::XML::Node' = error.content code = "" if defined?(error.property) == nil code = error.attributes['code'] else begin code = error["code"] rescue code = error.property('code') end end end raise OAI::Exception.new(, code) end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
4 5 6 |
# File 'lib/oai/client/response.rb', line 4 def doc @doc end |
#resumption_token ⇒ Object (readonly)
Returns the value of attribute resumption_token.
4 5 6 |
# File 'lib/oai/client/response.rb', line 4 def resumption_token @resumption_token end |