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


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

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

Instance Method Details

#each(&block) ⇒ Object


21
22
23
24
25
# File 'lib/rets4r/client/parsers/compact_nokogiri.rb', line 21

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

#to_aObject


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

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