Class: DescriptorsResponse
- Defined in:
- lib/refworks/descriptors/descriptors_response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#descriptors ⇒ Object
readonly
Returns the value of attribute descriptors.
-
#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) ⇒ DescriptorsResponse
constructor
A new instance of DescriptorsResponse.
Constructor Details
#initialize(raw_response) ⇒ DescriptorsResponse
Returns a new instance of DescriptorsResponse.
4 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 |
# File 'lib/refworks/descriptors/descriptors_response.rb', line 4 def initialize(raw_response) super(raw_response) if result_code != "200" @total = "0" return end # If results returned, process the descriptors and metadata @total = self.parsed_response["refworks"]["RWResult"]["RWDescriptor"]["total"] desc_list = self.parsed_response["refworks"]["RWResult"]["RWDescriptor"]["Descriptor"] # here we parse out into an array of actual Descriptor objects (even if only 1 ref returned) @descriptors = Array.new # The RefWorks API can return an array or a single element depending on how many descriptors were returned. if desc_list.class == Array desc_list.each do |rawdesc| @descriptors << Descriptor.new(rawdesc) end else # here, "descriptor_list" is just a hash representing a single descriptor # in other words, only one was returned @descriptors << Descriptor.new(desc_list) end end |
Instance Attribute Details
#descriptors ⇒ Object (readonly)
Returns the value of attribute descriptors.
2 3 4 |
# File 'lib/refworks/descriptors/descriptors_response.rb', line 2 def descriptors @descriptors end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
2 3 4 |
# File 'lib/refworks/descriptors/descriptors_response.rb', line 2 def total @total end |