lib/biomart/dataset.rb in biomart-0.1.3 vs lib/biomart/dataset.rb in biomart-0.1.4

- old
+ new

@@ -62,34 +62,52 @@ # the result of the count query. # # optional arguments: # # :filters:: hash of key-value pairs (filter => search term) + # :timeout:: set a timeout length for the request (secs) def count( args={} ) - args.merge!({ :count => "1" }) - result = request( :method => 'post', :url => @url, :query => generate_xml(args) ) + result = request( + :method => 'post', + :url => @url, + :timeout => args[:timeout], + :query => generate_xml( + :filters => args[:filters], + :attributes => args[:attributes], + :count => "1" + ) + ) return result.to_i end # Function to perform a Biomart search. # # optional arguments: # # :filters:: hash of key-value pairs (filter => search term) # :attributes:: array of attributes to retrieve # :process_results:: true/false - convert search results to object + # :timeout:: set a timeout length for the request (secs) # # By default will return a hash with the following: # # :headers:: array of headers # :data:: array of arrays containing search results # # But with the :process_results option will return an array of hashes, # where each hash represents a row of results (keyed by the attribute name). def search( args={} ) - response = request( :method => 'post', :url => @url, :query => generate_xml(args) ) - result = process_tsv( args, response ) - result = conv_results_to_a_of_h( result ) if args[:process_results] + response = request( + :method => 'post', + :url => @url, + :timeout => args[:timeout], + :query => generate_xml( + :filters => args[:filters], + :attributes => args[:attributes] + ) + ) + result = process_tsv( args, response ) + result = conv_results_to_a_of_h( result ) if args[:process_results] return result end # Utility function to build the Biomart query XML def generate_xml( args={} ) \ No newline at end of file