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