123456789_123456789_123456789_123456789_123456789_

Class: Nokogiri::HTML4::SAX::PushParser

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Nokogiri::XML::SAX::PushParser
Defined in: ext/nokogiri/html4_sax_push_parser.c,
ext/nokogiri/xml_sax_push_parser.c,
lib/nokogiri/html4/sax/push_parser.rb

Class Method Summary

::Nokogiri::XML::SAX::PushParser - Inherited

.new

Create a new PushParser with doc as the ::Nokogiri::HTML4::SAX Document, providing an optional file_name and encoding

Instance Attribute Summary

  • #document rw

    The Nokogiri::HTML4::SAX::Document on which the PushParser will be operating.

::Nokogiri::XML::SAX::PushParser - Inherited

#document

The ::Nokogiri::XML::SAX::Document on which the PushParser will be operating.

#options, #options=,
#replace_entities

Should this parser replace entities? & will get converted to ‘&’ if set to true.

#replace_entities=

Should this parser replace entities? & will get converted to ‘&’ if set to true.

Instance Method Summary

::Nokogiri::XML::SAX::PushParser - Inherited

#<<
#finish

Finish the parsing.

#write

Write a chunk of ::Nokogiri::XML to the PushParser.

#initialize_native

Initialize the push parser with xml_sax using filename

#native_write

Write chunk to PushParser.

Constructor Details

.new(doc = HTML4::SAX::Document.new, file_name = nil, encoding = "UTF-8") ⇒ PushParser

[ GitHub ]

  
# 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 (rw)

The Nokogiri::HTML4::SAX::Document on which the PushParser will be operating

[ GitHub ]

  
# File 'lib/nokogiri/html4/sax/push_parser.rb', line 9

attr_accessor :document

Instance Method Details

#<<(chunk, last_chunk = false)

Alias for #write.

[ GitHub ]

  
# File 'lib/nokogiri/html4/sax/push_parser.rb', line 26

alias_method :<<, :write

#finish

Finish the parsing. This method is only necessary for Nokogiri::HTML4::SAX::Document#end_document to be called.

[ GitHub ]

  
# File 'lib/nokogiri/html4/sax/push_parser.rb', line 31

def finish
  write("", true)
end

#initialize_native(xml_sax, filename) (private)

#native_write(chunk, last_chunk) (private)

#write(chunk, last_chunk = false) Also known as: #<<

Write a chunk of ::Nokogiri::HTML to the PushParser. Any callback methods that can be called will be called immediately.

[ GitHub ]

  
# File 'lib/nokogiri/html4/sax/push_parser.rb', line 23

def write(chunk, last_chunk = false)
  native_write(chunk, last_chunk)
end