class SPImaging::Protocol

Public Class Methods

instance() click to toggle source
# File lib/spimaging/protocol.rb, line 6
def self.instance
  @instance ||= self.new Configuration.current
end
new(config) click to toggle source
# File lib/spimaging/protocol.rb, line 10
def initialize(config)
  @base_url = config['base_url']
  @render_path = config['render_path']
  @username = config['username']
  @password = config['password']

  url = URI.parse @base_url
  @http = Net::HTTP.new url.host, url.port
  @http.use_ssl = (url.scheme =~ /https/i)

end

Public Instance Methods

download_images(xml) click to toggle source
# File lib/spimaging/protocol.rb, line 22
def download_images(xml)
  request = Net::HTTP::Post.new URI.join(@base_url, "image/retrieve").to_s
  request.body = xml
  request['Accept'] = 'text/html'
  request['Content-Type'] = 'application/xml'
  request.basic_auth @username, @password

  response = http.request request

  SPImaging::ShowImagesResponse.new response.code, response.body, response.content_type, response['content-encoding'], response['content-disposition']
end

Private Instance Methods

http() click to toggle source
# File lib/spimaging/protocol.rb, line 36
def http
  @http.start unless @http.started?
  @http
end
render_url() click to toggle source
# File lib/spimaging/protocol.rb, line 41
def render_url
  URI.join(@base_url, @render_path).to_s
end