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