Class: RETS4R::Client::CompactNokogiriParser::CompactDocument

Inherits:
Nokogiri::XML::SAX::Document
  • Object
show all
Defined in:
lib/rets4r/client/parsers/compact_nokogiri.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompactDocument


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

def initialize
  @results = []
  @data_element = nil
  @reply_code = nil
  @columns_element = nil
  @proc = nil
end

Instance Attribute Details

#proc=(value) ⇒ Object (writeonly)

Sets the attribute proc


29
30
31
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 29

def proc=(value)
  @proc = value
end

#resultsObject (readonly)

Returns the value of attribute results


28
29
30
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 28

def results
  @results
end

Instance Method Details

#characters(string) ⇒ Object


76
77
78
79
80
81
82
83
84
85
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 76

def characters string
  if @columns_element
    @string << string
  elsif @data_element
    @string << string
  elsif @reply_code
    throw string
    @reply_code = false
  end
end

#end_element(name) ⇒ Object


65
66
67
68
69
70
71
72
73
74
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 65

def end_element name
  case name
  when 'COLUMNS'
    @columns_element = false
    @columns = RETS4R::ResponseDocument::Search.split_raw_headers(@string, @delimiter)
  when 'DATA'
    @data_element = false
    handle_row
  end
end

#start_element(name, attrs = []) ⇒ Object


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 38

def start_element name, attrs = []
  case name
  when 'DELIMITER'    # This is a workaround for the old attribute handling in nokogiri

    @delimiter = if Array === attrs.last       # In nokogiri >= 1.4.4, we recieve attributes as an assoc list,
       # which also includes the current namespaces in the context

      attrs.last.last.to_i.chr
    else
      if $VERBOSE
        warn "#{caller.first}: warning: support for Nokogiri <= 1.4.3.1 is deprecated and will be removed by rets4r 2.0; Please upgrade to Nokogiri 1.4.4 or newer"
      end      # Earlier versions would flatten attributes, making it painful for
      # namespace aware parsing.

      attrs.last.to_i.chr
    end
  when 'COLUMNS'
    @columns_element = true
    @string = ''
  when 'DATA'
    @data_element = true
    @string = ''
  when 'RETS'
    handle_body_start attrs
  end
end