Class: RETS4R::Client::CompactNokogiriParser

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rets4r/client/parsers/compact_nokogiri.rb

Defined Under Namespace

Classes: CompactDocument

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ CompactNokogiriParser

Returns a new instance of CompactNokogiriParser.



6
7
8
9
10
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 6

def initialize(io)
  @doc    = CompactDocument.new
  @parser = Nokogiri::XML::SAX::Parser.new(@doc)
  @io     = io
end

Instance Method Details

#each(&block) ⇒ Object



17
18
19
20
21
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 17

def each(&block)
  @doc.proc = block.to_proc
  @parser.parse(@io)
  nil
end

#to_aObject



12
13
14
15
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 12

def to_a
  @parser.parse(@io) if @doc.results.empty?
  @doc.results
end