Class: Nokogiri::HTML5::Document
- Inherits:
-
Nokogiri::HTML::Document
- Object
- Nokogiri::HTML::Document
- Nokogiri::HTML5::Document
- Defined in:
- lib/nokogumbo/html5/document.rb
Class Method Summary collapse
- .parse(string_or_io, url = nil, encoding = nil, **options) {|options| ... } ⇒ Object
- .read_io(io, url = nil, encoding = nil, **options) ⇒ Object
- .read_memory(string, url = nil, encoding = nil, **options) ⇒ Object
Instance Method Summary collapse
Class Method Details
.parse(string_or_io, url = nil, encoding = nil, **options) {|options| ... } ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nokogumbo/html5/document.rb', line 4 def self.parse(string_or_io, url = nil, encoding = nil, **, &block) yield if block_given? string_or_io = '' unless string_or_io if string_or_io.respond_to?(:encoding) && string_or_io.encoding.name != 'ASCII-8BIT' encoding ||= string_or_io.encoding.name end if string_or_io.respond_to?(:read) && string_or_io.respond_to?(:path) url ||= string_or_io.path end unless string_or_io.respond_to?(:read) || string_or_io.respond_to?(:to_str) raise ArgumentError.new("not a string or IO object") end do_parse(string_or_io, url, encoding, ) end |
.read_io(io, url = nil, encoding = nil, **options) ⇒ Object
21 22 23 24 |
# File 'lib/nokogumbo/html5/document.rb', line 21 def self.read_io(io, url = nil, encoding = nil, **) raise ArgumentError.new("io object doesn't respond to :read") unless io.respond_to?(:read) do_parse(io, url, encoding, ) end |
.read_memory(string, url = nil, encoding = nil, **options) ⇒ Object
26 27 28 29 |
# File 'lib/nokogumbo/html5/document.rb', line 26 def self.read_memory(string, url = nil, encoding = nil, **) raise ArgumentError.new("string object doesn't respond to :to_str") unless string.respond_to?(:to_str) do_parse(string, url, encoding, ) end |
Instance Method Details
#fragment(tags = nil) ⇒ Object
31 32 33 |
# File 'lib/nokogumbo/html5/document.rb', line 31 def fragment( = nil) DocumentFragment.new(self, , self.root) end |
#to_xml(options = {}, &block) ⇒ Object
35 36 37 38 39 |
# File 'lib/nokogumbo/html5/document.rb', line 35 def to_xml( = {}, &block) # Bypass XML::Document#to_xml which doesn't add # XML::Node::SaveOptions::AS_XML like XML::Node#to_xml does. XML::Node.instance_method(:to_xml).bind(self).call(, &block) end |