Class | Bio::PSORT::CGIDriver |
In: |
lib/bio/appl/psort.rb
|
Parent: | Object |
A generic CGI client class for Bio::PSORT::* classes. The class provides an interface for CGI argument processing and output report parsing.
class NewClient < CGIDriver def initialize(host, path) super(host, path) end end private def make_args(query) # ... end def parse_report(output) # ... end
args | [RW] | CGI query argument in Hash ({key => value, …}). |
report | [R] | CGI output raw text |
Sets remote host name and cgi path or uri.
CGIDriver.new("localhost", "/cgi-bin/psort_www.pl") CGIDriver.new("http://localhost/cgi-bin/psort_www.pl") CGIDriver.new(URI.parse("http://localhost/cgi-bin/psort_www.pl"))
# File lib/bio/appl/psort.rb, line 94 94: def initialize(host = '', path = '') 95: case host.to_s 96: when /^http:/ 97: uri = host.to_s 98: else 99: uri = 'http://' + host + '/' + path 100: end 101: @uri = URI.parse(uri) 102: @args = {} 103: @report = '' 104: end
Executes a CGI ``query’’ and returns aReport
# File lib/bio/appl/psort.rb, line 108 108: def exec(query) 109: data = make_args(query) 110: 111: begin 112: result = nil 113: Bio::Command.start_http(@uri.host) {|http| 114: result = http.post(@uri.path, data) 115: } 116: @report = result.body 117: output = parse_report(@report) 118: end 119: 120: return output 121: end