Class: Puree::Extractor::ResearchOutput
- Defined in:
- lib/puree/extractor/research_output.rb
Overview
Research output extractor.
Instance Method Summary collapse
-
#count(params = {}) ⇒ Integer
Count of records available.
- #find(id) ⇒ Puree::Model::ResearchOutput?
-
#random(params = {}) ⇒ Puree::Model::ResearchOutput or subclass?
Random record.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Puree::Extractor::Resource
Instance Method Details
#count(params = {}) ⇒ Integer
Count of records available.
21 22 23 |
# File 'lib/puree/extractor/research_output.rb', line 21 def count(params = {}) record_count :research_output, params end |
#find(id) ⇒ Puree::Model::ResearchOutput?
11 12 13 14 15 |
# File 'lib/puree/extractor/research_output.rb', line 11 def find(id) super id: id, api_resource_type: :research_output, xml_extractor_resource_type: :research_output end |
#random(params = {}) ⇒ Puree::Model::ResearchOutput or subclass?
Random record. Includes the metadata from Puree::Model::ResearchOutput as a minimum.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/puree/extractor/research_output.rb', line 29 def random(params = {}) client = Puree::REST::Client.new @config offset = rand(0..count(params)-1) params[:size] = 1 params[:offset] = offset response = client.research_outputs.all_complex params: params research_outputs_hash = Puree::XMLExtractor::Collection.research_outputs response.to_s research_outputs_array = [] research_outputs_hash.each do |k, v| research_outputs_array += v end return nil if research_outputs_array.empty? research_outputs_array[0] end |