Sha256: 7fe61b3d0e159a776e2fe947a8784be97a63701833bd03f0893201c85d20f0d1
Contents?: true
Size: 942 Bytes
Versions: 9
Compression:
Stored size: 942 Bytes
Contents
# Parses XML response containing 'COMPACT' data format. require 'cgi' module RETS4R class Client class CompactDataParser def parse_results(doc) delimiter = doc.get_elements('/RETS/DELIMITER')[0].attributes['value'].to_i.chr columns = doc.get_elements('/RETS/COLUMNS')[0] rows = doc.get_elements('/RETS/DATA') parse_data(columns, rows, delimiter) end def parse_data(column_element, row_elements, delimiter = "\t") column_names = column_element.text.split(delimiter) result = [] data = row_elements.each do |data_row| data_row = data_row.text.split(delimiter) row_result = {} column_names.each_with_index do |col, x| row_result[col] = data_row[x] end row_result.reject! { |k,v| k.blank? } result << row_result end return result end end end end
Version data entries
9 entries across 9 versions & 2 rubygems