class Bio::DDBJ::REST::WABItemplate
Bio::DDBJ::REST::WABItemplate is a private class to provide common methods to access DDBJ Web API for Biology (WABI) services by using REST protocol.
Normal users should not use the class directly.
Constants
- WABI_HOST
hostname for the WABI service
- WABI_PATH
path for the WABI service
Public Class Methods
new()
click to toggle source
Creates a new object.
# File lib/bio/io/ddbjrest.rb, line 77 def initialize @http = Bio::Command.new_http(WABI_HOST) @service = self.class.to_s.split(/\:\:/)[-1] end
Private Class Methods
def_wabi(array)
click to toggle source
# File lib/bio/io/ddbjrest.rb, line 119 def self.def_wabi(array) define_wabi_method(array) end
def_wabi_async(array)
click to toggle source
# File lib/bio/io/ddbjrest.rb, line 132 def self.def_wabi_async(array) m = array[0] def_wabi_custom(array) module_eval "def #{m}(*arg) ret = _#{m}(*arg) if /Your +requestId +is\s*\:\s*(.+)\s*/i =~ ret.to_s then return $1 else raise \"unknown return value: \#\{ret.inspect\}\" end end" self end
def_wabi_custom(array)
click to toggle source
# File lib/bio/io/ddbjrest.rb, line 124 def self.def_wabi_custom(array) ruby_method_name = '_' + array[0] define_wabi_method(array, ruby_method_name) module_eval "private :#{ruby_method_name}" self end
define_wabi_method(array, ruby_method_name = nil, public_method_name = nil)
click to toggle source
# File lib/bio/io/ddbjrest.rb, line 98 def self.define_wabi_method(array, ruby_method_name = nil, public_method_name = nil) wabi_method_name = array[0] ruby_method_name ||= wabi_method_name public_method_name ||= wabi_method_name arg = array[1..-1] arguments = arg.join(', ') parameters = "{" + arg.collect { |x| "#{x.dump} => #{x}" }.join(", ") + "}" module_eval "def #{ruby_method_name}(#{arguments}) param = #{parameters} _wabi_post(#{wabi_method_name.dump}, param) end def self.#{public_method_name}(#{arguments}) self.new.#{public_method_name}(#{arguments}) end" self end
Private Instance Methods
_wabi_post(method_name, param)
click to toggle source
(private) query to the service by using POST method
# File lib/bio/io/ddbjrest.rb, line 83 def _wabi_post(method_name, param) parameters = { 'service' => @service, 'method' => method_name } parameters.update(param) #$stderr.puts parameters.inspect r = Bio::Command.http_post_form(@http, WABI_PATH, parameters) #$stderr.puts r.inspect #$stderr.puts "-"*78 #$stderr.puts r.body #$stderr.puts "-"*78 r.body end