Class: RETS4R::Client::CompactDataParser
- Inherits:
-
Object
- Object
- RETS4R::Client::CompactDataParser
- Defined in:
- lib/rets4r/client/parsers/compact.rb
Instance Method Summary collapse
Instance Method Details
#parse_data(column_element, row_elements, delimiter = "\t") ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rets4r/client/parsers/compact.rb', line 18 def parse_data(column_element, row_elements, delimiter = "\t") column_names = column_element.to_s.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.nil? || k.empty? } result << row_result end return result end |
#parse_results(doc) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/rets4r/client/parsers/compact.rb', line 8 def parse_results(doc) delimiter = doc.get_elements('/RETS/DELIMITER')[0] && 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 |