Sha256: 9968bea19045b6dbefc5f5f3178e724bea2720430921a462c8e7bb4cf1138991

Contents?: true

Size: 413 Bytes

Versions: 3

Compression:

Stored size: 413 Bytes

Contents

module RTurk::XmlUtilities

  def xml_to_hash(noko_xml)
    hash = {}
    noko_xml.children.each do |child|
      next if child.blank?
      if child.text?
        return child.text
      else
        hash[child.name] = xml_to_hash(child)
      end
    end
    hash
  end

  def map_content(xml_obj, hash)
    hash.each_pair do |k,v|
      self.send("#{k.to_s}=", xml_obj.xpath(v).inner_text)
    end
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rturk-2.0.2 lib/rturk/xml_utilities.rb
rturk-2.0.1 lib/rturk/xml_utilities.rb
rturk-2.0.0 lib/rturk/xml_utilities.rb