Class: RetrieveResponse
- Defined in:
- lib/refworks/retrieve/retrieve_response.rb
Direct Known Subclasses
ReferenceGetResponse, RetrieveAdvancesearchResponse, RetrieveAllResponse, RetrieveAuthorResponse, RetrieveByidResponse, RetrieveDescriptorResponse, RetrieveDupResponse, RetrieveFolderResponse, RetrieveModsinceResponse, RetrieveNofolderResponse, RetrievePeriodicalResponse, RetrieveQuickResponse, RetrieveSavedResponse, RetrieveSpecialfolderResponse
Instance Attribute Summary collapse
-
#references ⇒ Object
readonly
Returns the value of attribute references.
-
#total_hits ⇒ Object
readonly
Returns the value of attribute total_hits.
-
#total_returned ⇒ Object
readonly
Returns the value of attribute total_returned.
Attributes inherited from Response
#body, #parsed_response, #process_time, #result_code, #result_msg, #result_msg_code
Instance Method Summary collapse
-
#initialize(raw_response) ⇒ RetrieveResponse
constructor
A new instance of RetrieveResponse.
Constructor Details
#initialize(raw_response) ⇒ RetrieveResponse
Returns a new instance of RetrieveResponse.
5 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 33 |
# File 'lib/refworks/retrieve/retrieve_response.rb', line 5 def initialize(raw_response) super(raw_response) if result_code != "200" @total_hits = "0" @total_returned = "0" return end # If results returned, process the references and metadata @total_hits = self.parsed_response["refworks"]["RWResult"]["RetrieveResult"]["totalHits"] @total_returned = self.parsed_response["refworks"]["RWResult"]["RetrieveResult"]["totalReturned"] refs = self.parsed_response["refworks"]["RWResult"]["RetrieveResult"]["reference"] # here we parse out references into an array of actual Reference objects (even if only 1 ref returned) @references = Array.new # The RefWorks API can return an array or a single element depending on how many references were returned. if refs.class == Array refs.each do |ref| @references << Reference.new(ref) end else # here, "refs" is just a hash representing a single reference # in other words, only one reference was returned @references << Reference.new(refs) end end |
Instance Attribute Details
#references ⇒ Object (readonly)
Returns the value of attribute references.
3 4 5 |
# File 'lib/refworks/retrieve/retrieve_response.rb', line 3 def references @references end |
#total_hits ⇒ Object (readonly)
Returns the value of attribute total_hits.
3 4 5 |
# File 'lib/refworks/retrieve/retrieve_response.rb', line 3 def total_hits @total_hits end |
#total_returned ⇒ Object (readonly)
Returns the value of attribute total_returned.
3 4 5 |
# File 'lib/refworks/retrieve/retrieve_response.rb', line 3 def total_returned @total_returned end |