Sha256: b9d35128e4e095317414ad729c320cee10020f5ace86dfd5881b59b359301172
Contents?: true
Size: 1.21 KB
Versions: 6
Compression:
Stored size: 1.21 KB
Contents
require 'cgi' require 'uri' module RTurk class Question attr_accessor :url, :url_params, :frame_height def initialize(url, opts = {}) @url = url self.frame_height = opts.delete(:frame_height) || 400 self.url_params = opts end def querystring @url_params.collect { |key, value| [CGI.escape(key.to_s), CGI.escape(value.to_s)].join('=') }.join('&') end def url unless querystring.empty? # slam the params onto url, if url already has params, add 'em with a & @url.index('?') ? "#{@url}&#{querystring}" : "#{@url}?#{querystring}" else @url end end def params @url_params end def params=(param_set) @url_params = param_set end def to_params raise RTurk::MissingParameters, "needs a url to build an external question" unless @url # TODO: update the xmlns schema... maybe xml = <<-XML <ExternalQuestion xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2006-07-14/ExternalQuestion.xsd"> <ExternalURL>#{url}</ExternalURL> <FrameHeight>#{frame_height}</FrameHeight> </ExternalQuestion> XML xml end end end
Version data entries
6 entries across 6 versions & 1 rubygems