Class: Nokogiri::HTML::Document
- Inherits:
-
Object
- Object
- Nokogiri::HTML::Document
- Defined in:
- lib/rusty/nokogiri_ext.rb
Instance Method Summary collapse
-
#meta_encoding ⇒ Object
returns the encoding as defined in the meta node.
Instance Method Details
#meta_encoding ⇒ Object
returns the encoding as defined in the meta node. Available only in HTML documents.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rusty/nokogiri_ext.rb', line 63 def # HTML5 css("meta[charset]").each do || next unless charset = .attribute("charset") return charset.value end # HTML4 css("meta[http-equiv=content-type]").each do || next unless content = .attribute("content") next unless content.value.split("; ").last =~ /^charset=(.*)/ return $1 end nil end |