Sha256: 4d6134c8d2824725df6e117c90c5add0922e5dde621ab303e43078aa7ac80ee7

Contents?: true

Size: 588 Bytes

Versions: 32

Compression:

Stored size: 588 Bytes

Contents

module RTurk

  class AnswerParser

    require 'cgi'

    def self.parse(xml)
      answer_xml = Nokogiri::XML(CGI.unescapeHTML(xml.to_s))
      answer_hash = {}
      answers = answer_xml.xpath('//xmlns:Answer')
      answers.each do |answer|
        key, value = nil, nil
        answer.children.each do |child|
          next if child.blank?
          if child.name == 'QuestionIdentifier'
            key = child.inner_text
          else
            value = child.inner_text
          end
        end
        answer_hash[key] = value
      end
      answer_hash
    end


  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
rturk-2.12.1 lib/rturk/parsers/answer_parser.rb
rturk-2.12.0 lib/rturk/parsers/answer_parser.rb
rturk-2.11.3 lib/rturk/parsers/answer_parser.rb
rturk-2.11.2 lib/rturk/parsers/answer_parser.rb
rturk-2.11.1 lib/rturk/parsers/answer_parser.rb
rturk-2.11.0 lib/rturk/parsers/answer_parser.rb
rturk-2.10.3 lib/rturk/parsers/answer_parser.rb
rturk-2.10.2 lib/rturk/parsers/answer_parser.rb
rturk-2.10.1 lib/rturk/parsers/answer_parser.rb
rturk-2.10.0 lib/rturk/parsers/answer_parser.rb
rturk-2.9.0 lib/rturk/parsers/answer_parser.rb
rturk-2.8.0 lib/rturk/parsers/answer_parser.rb
rturk-2.7.0 lib/rturk/parsers/answer_parser.rb
rturk-2.6.0 lib/rturk/parsers/answer_parser.rb
rturk-2.5.2 lib/rturk/parsers/answer_parser.rb
rturk-2.5.0 lib/rturk/parsers/answer_parser.rb
rturk-2.4.1 lib/rturk/parsers/answer_parser.rb
rturk-2.4.0 lib/rturk/parsers/answer_parser.rb
rturk-2.3.6 lib/rturk/parsers/answer_parser.rb
rturk-2.3.5 lib/rturk/parsers/answer_parser.rb