Class: FoldersResponse
- Defined in:
- lib/refworks/folders/folders_response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#folders ⇒ Object
readonly
Returns the value of attribute folders.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Attributes inherited from Response
#body, #parsed_response, #process_time, #result_code, #result_msg, #result_msg_code
Instance Method Summary collapse
-
#initialize(raw_response) ⇒ FoldersResponse
constructor
A new instance of FoldersResponse.
Constructor Details
#initialize(raw_response) ⇒ FoldersResponse
Returns a new instance of FoldersResponse.
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 |
# File 'lib/refworks/folders/folders_response.rb', line 5 def initialize(raw_response) super(raw_response) if result_code != "200" @total = "0" return end # If results returned, process the folders and metadata @total = self.parsed_response["refworks"]["RWResult"]["RWFolders"]["total"] folder_list = self.parsed_response["refworks"]["RWResult"]["RWFolders"]["Folders"] # here we parse out folders into an array of actual Author objects (even if only 1 ref returned) @folders = Array.new # The RefWorks API can return an array or a single element depending on how many folders were returned. if folder_list.class == Array folder_list.each do |rawfolder| @folders << Folder.new(rawfolder) end else # here, "folder_list" is just a hash representing a single folder # in other words, only one folder was returned @folders << Folder.new(folder_list) end end |
Instance Attribute Details
#folders ⇒ Object (readonly)
Returns the value of attribute folders.
3 4 5 |
# File 'lib/refworks/folders/folders_response.rb', line 3 def folders @folders end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
3 4 5 |
# File 'lib/refworks/folders/folders_response.rb', line 3 def total @total end |