Class: RETS4R::Client::ResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rets4r/client/parsers/response_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse_count(xml) ⇒ Object



39
40
41
42
43
# File 'lib/rets4r/client/parsers/response_parser.rb', line 39

def parse_count(xml)
  parse_common(xml) do |doc|
    doc.get_elements('/RETS/COUNT')[0].attributes['Records']
  end
end

#parse_key_value(xml) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rets4r/client/parsers/response_parser.rb', line 8

def parse_key_value(xml)
  parse_common(xml) do |doc|
    parsed = nil
    first_child = doc.get_elements('/RETS/RETS-RESPONSE')[0] ? doc.get_elements('/RETS/RETS-RESPONSE')[0] : doc.get_elements('/RETS')[0]
    unless first_child.nil?
      parsed = {}
      first_child.text.each do |line|
        (key, value) = line.strip.split('=')
        key.strip! if key
        value.strip! if value
        parsed[key] = value
      end
    else
      raise 'Response was not a proper RETS XML doc!'
    end

    if parsed.nil?
      raise "Response was not valid key/value format"
    else
      parsed
    end
  end
end

#parse_metadata(xml, format) ⇒ Object



45
46
47
48
49
# File 'lib/rets4r/client/parsers/response_parser.rb', line 45

def (xml, format)
  parse_common(xml) do |doc|
    return REXML::Document.new(xml)
  end
end

#parse_object_response(xml) ⇒ Object



51
52
53
54
55
# File 'lib/rets4r/client/parsers/response_parser.rb', line 51

def parse_object_response(xml)
  parse_common(xml) do |doc|
    # XXX
  end
end

#parse_results(xml, format) ⇒ Object



32
33
34
35
36
37
# File 'lib/rets4r/client/parsers/response_parser.rb', line 32

def parse_results(xml, format)
  parse_common(xml) do |doc|
    parser = get_parser_by_name(format)
    parser.parse_results(doc)
  end
end