Class: Bio::PSORT::CGIDriver
Overview
Generic CGI client class
A generic CGI client class for Bio::PSORT::* classes. The class provides an interface for CGI argument processing and output report parsing.
Example
class NewClient < CGIDriver
def initialize(host, path)
super(host, path)
end
end
private
def make_args(query)
# ...
end
def parse_report(output)
# ...
end
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
CGI query argument in Hash (=> value, …).
-
#report ⇒ Object
readonly
CGI output raw text.
Instance Method Summary collapse
-
#exec(query) ⇒ Object
Executes a CGI “query” and returns aReport.
-
#initialize(host = '', path = '') ⇒ CGIDriver
constructor
Sets remote host name and cgi path or uri.
Constructor Details
#initialize(host = '', path = '') ⇒ CGIDriver
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/bio/appl/psort.rb', line 94 def initialize(host = '', path = '') case host.to_s when /^http:/ uri = host.to_s else uri = 'http://' + host + '/' + path end @uri = URI.parse(uri) @args = {} @report = '' end |
Instance Attribute Details
#args ⇒ Object
CGI query argument in Hash (=> value, …).
78 79 80 |
# File 'lib/bio/appl/psort.rb', line 78 def args @args end |
#report ⇒ Object (readonly)
CGI output raw text
81 82 83 |
# File 'lib/bio/appl/psort.rb', line 81 def report @report end |
Instance Method Details
#exec(query) ⇒ Object
Executes a CGI “query” and returns aReport
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/bio/appl/psort.rb', line 108 def exec(query) data = make_args(query) begin result = nil Bio::Command.start_http(@uri.host) {|http| result = http.post(@uri.path, data) } @report = result.body output = parse_report(@report) end return output end |