Class: Rets::Parser::Compact::SaxParser
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- Rets::Parser::Compact::SaxParser
- Defined in:
- lib/rets/parser/compact.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#delimiter ⇒ Object
readonly
Returns the value of attribute delimiter.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #characters(string) ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize ⇒ SaxParser
constructor
A new instance of SaxParser.
- #start_element(name, attrs = []) ⇒ Object
Constructor Details
#initialize ⇒ SaxParser
Returns a new instance of SaxParser.
25 26 27 28 29 30 31 32 |
# File 'lib/rets/parser/compact.rb', line 25 def initialize @results = [] @columns = '' @result_index = nil @delimiter = nil @columns_start = false @data_start = false end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
23 24 25 |
# File 'lib/rets/parser/compact.rb', line 23 def columns @columns end |
#delimiter ⇒ Object (readonly)
Returns the value of attribute delimiter.
23 24 25 |
# File 'lib/rets/parser/compact.rb', line 23 def delimiter @delimiter end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
23 24 25 |
# File 'lib/rets/parser/compact.rb', line 23 def results @results end |
Instance Method Details
#characters(string) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rets/parser/compact.rb', line 54 def characters string if @columns_start @columns << string end if @result_index @results[@result_index] ||= '' @results[@result_index] << string end end |
#end_element(name) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/rets/parser/compact.rb', line 45 def end_element name case name when 'COLUMNS' @columns_start = false when 'DATA' @result_index = nil end end |
#start_element(name, attrs = []) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rets/parser/compact.rb', line 34 def start_element name, attrs=[] case name when 'DELIMITER' @delimiter = attrs.last.last.to_i.chr when 'COLUMNS' @columns_start = true when 'DATA' @result_index = @results.size end end |