Class: Nokogiri::HTML::Document::EncodingReader::SAXHandler
- Inherits:
-
XML::SAX::Document
- Object
- XML::SAX::Document
- Nokogiri::HTML::Document::EncodingReader::SAXHandler
- Defined in:
- lib/nokogiri/html/document.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
Instance Method Summary collapse
Methods inherited from XML::SAX::Document
#cdata_block, #characters, #comment, #end_document, #end_element, #end_element_namespace, #error, #start_document, #start_element_namespace, #warning, #xmldecl
Instance Attribute Details
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
133 134 135 |
# File 'lib/nokogiri/html/document.rb', line 133 def encoding @encoding end |
Instance Method Details
#found(encoding) ⇒ Object
135 136 137 138 |
# File 'lib/nokogiri/html/document.rb', line 135 def found(encoding) @encoding = encoding throw :found end |
#not_found(encoding) ⇒ Object
140 141 142 |
# File 'lib/nokogiri/html/document.rb', line 140 def not_found(encoding) found nil end |
#start_element(name, attrs = []) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/nokogiri/html/document.rb', line 144 def start_element(name, attrs = []) case name when /\A(?:div|h1|img|p|br)\z/ not_found when 'meta' attr = Hash[attrs] charset = attr['charset'] and found charset http_equiv = attr['http-equiv'] and http_equiv.match(/\AContent-Type\z/i) and content = attr['content'] and m = content.match(/;\s*charset\s*=\s*([\w-]+)/) and found m[1] end end |