Class: Response
- Inherits:
-
Object
- Object
- Response
- Defined in:
- lib/refworks/response.rb
Direct Known Subclasses
AuthenticationResponse, AuthorsResponse, DescriptorsResponse, FoldersResponse, ImportfilterResponse, ManuscriptResponse, PeriodicalsResponse, PropertiesResponse, ReferenceResponse, RetrieveCountResponse, RetrieveResponse, SavedsearchResponse
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#parsed_response ⇒ Object
readonly
Returns the value of attribute parsed_response.
-
#process_time ⇒ Object
readonly
Returns the value of attribute process_time.
-
#result_code ⇒ Object
readonly
Returns the value of attribute result_code.
-
#result_msg ⇒ Object
readonly
Returns the value of attribute result_msg.
-
#result_msg_code ⇒ Object
readonly
Returns the value of attribute result_msg_code.
Instance Method Summary collapse
-
#initialize(raw_response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(raw_response) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/refworks/response.rb', line 5 def initialize(raw_response) # The RefWorks API emits invalid XML. Specifically, when the session is invalid, the ResultMsg field # which comes back contains some illegal raw characters. This is the only set of transformations I # could find which completely eliminate the junk characters. # Trying to work around the malformed response bug p raw_response.body # Replace non UTF-8 chars with the empty string raw_response.body.encode!('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '') # Remove characters which are not allowed to appear in XML messages raw_response.body.gsub!(/[\u0001-\u0019]/,'') p raw_response.body @body = raw_response.body @parsed_response = raw_response.parsed_response @result_code = parsed_response["refworks"]["RWResult"]["result"] @process_time = parsed_response["refworks"]["RWResult"]["processTime"] @result_msg = parsed_response["refworks"]["RWResult"]["resultMsg"] @result_msg_code = parsed_response["refworks"]["RWResult"]["resultMsgCode"] end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/refworks/response.rb', line 3 def body @body end |
#parsed_response ⇒ Object (readonly)
Returns the value of attribute parsed_response.
3 4 5 |
# File 'lib/refworks/response.rb', line 3 def parsed_response @parsed_response end |
#process_time ⇒ Object (readonly)
Returns the value of attribute process_time.
3 4 5 |
# File 'lib/refworks/response.rb', line 3 def process_time @process_time end |
#result_code ⇒ Object (readonly)
Returns the value of attribute result_code.
3 4 5 |
# File 'lib/refworks/response.rb', line 3 def result_code @result_code end |
#result_msg ⇒ Object (readonly)
Returns the value of attribute result_msg.
3 4 5 |
# File 'lib/refworks/response.rb', line 3 def result_msg @result_msg end |
#result_msg_code ⇒ Object (readonly)
Returns the value of attribute result_msg_code.
3 4 5 |
# File 'lib/refworks/response.rb', line 3 def result_msg_code @result_msg_code end |