Class: ImportfilterResponse
- Defined in:
- lib/refworks/importfilter/importfilter_response.rb
Direct Known Subclasses
ImportfilterAllavailableResponse, ImportfilterAllglobalResponse, ImportfilterFavoritesResponse, ImportfilterSearchResponse
Instance Attribute Summary collapse
-
#importfilters ⇒ Object
readonly
Returns the value of attribute importfilters.
-
#totalFilters ⇒ Object
readonly
Returns the value of attribute totalFilters.
Attributes inherited from Response
#body, #parsed_response, #process_time, #result_code, #result_msg, #result_msg_code
Instance Method Summary collapse
-
#initialize(raw_response) ⇒ ImportfilterResponse
constructor
A new instance of ImportfilterResponse.
Constructor Details
#initialize(raw_response) ⇒ ImportfilterResponse
Returns a new instance of ImportfilterResponse.
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 31 32 33 34 |
# File 'lib/refworks/importfilter/importfilter_response.rb', line 4 def initialize(raw_response) super(raw_response) if result_code != "200" @totalFilters = "0" return end @totalFilters = self.parsed_response["refworks"]["RWResult"]["ImportFilterResult"]["totalFilters"] # e.g. case of no favorites if @totalFilters == "0" return end # If results returned, process the importfilters and metadata filter_list = self.parsed_response["refworks"]["RWResult"]["ImportFilterResult"]["ImportFilter"] # here we parse out authors into an array of actual Importfilter objects (even if only 1 ref returned) @importfilters = Array.new # The RefWorks API can return an array or a single element depending on how many importfilters were returned. if filter_list.class == Array filter_list.each do |rawfilter| @importfilters << Importfilter.new(rawfilter) end else # here, "filter_list" is just a hash representing a single author # in other words, only one importfilter was returned @importfilters << Importfilter.new(filter_list) end end |
Instance Attribute Details
#importfilters ⇒ Object (readonly)
Returns the value of attribute importfilters.
2 3 4 |
# File 'lib/refworks/importfilter/importfilter_response.rb', line 2 def importfilters @importfilters end |
#totalFilters ⇒ Object (readonly)
Returns the value of attribute totalFilters.
2 3 4 |
# File 'lib/refworks/importfilter/importfilter_response.rb', line 2 def totalFilters @totalFilters end |