Class: Nokogiri::HTML4::SAX::PushParser
- Inherits:
-
XML::SAX::PushParser
- Object
- XML::SAX::PushParser
- Nokogiri::HTML4::SAX::PushParser
- Defined in:
- lib/nokogiri/html4/sax/push_parser.rb,
ext/nokogiri/html4_sax_push_parser.c
Overview
Instance Attribute Summary collapse
-
#document ⇒ Object
The Nokogiri::HTML4::SAX::Document on which the PushParser will be operating.
Instance Method Summary collapse
-
#finish ⇒ Object
Finish the parsing.
-
#initialize(doc = HTML4::SAX::Document.new, file_name = nil, encoding = 'UTF-8') ⇒ PushParser
constructor
A new instance of PushParser.
-
#write(chunk, last_chunk = false) ⇒ Object
(also: #<<)
Write a
chunk
of HTML to the PushParser.
Methods inherited from XML::SAX::PushParser
#options, #options=, #replace_entities, #replace_entities=
Constructor Details
#initialize(doc = HTML4::SAX::Document.new, file_name = nil, encoding = 'UTF-8') ⇒ PushParser
Returns a new instance of PushParser.
11 12 13 14 15 16 17 18 |
# File 'lib/nokogiri/html4/sax/push_parser.rb', line 11 def initialize(doc = HTML4::SAX::Document.new, file_name = nil, encoding = 'UTF-8') @document = doc @encoding = encoding @sax_parser = HTML4::SAX::Parser.new(doc, @encoding) ## Create our push parser context initialize_native(@sax_parser, file_name, encoding) end |
Instance Attribute Details
#document ⇒ Object
The Nokogiri::HTML4::SAX::Document on which the PushParser will be operating
9 10 11 |
# File 'lib/nokogiri/html4/sax/push_parser.rb', line 9 def document @document end |
Instance Method Details
#finish ⇒ Object
Finish the parsing. This method is only necessary for Nokogiri::HTML4::SAX::Document#end_document to be called.
31 32 33 |
# File 'lib/nokogiri/html4/sax/push_parser.rb', line 31 def finish write '', true end |
#write(chunk, last_chunk = false) ⇒ Object Also known as: <<
Write a chunk
of HTML to the PushParser. Any callback methods that can be called will be called immediately.
23 24 25 |
# File 'lib/nokogiri/html4/sax/push_parser.rb', line 23 def write chunk, last_chunk = false native_write(chunk, last_chunk) end |