From c99eaa709881bb7298a4f9df9ebafad24c5776f7 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Fri, 5 Feb 2021 17:13:33 -0500 Subject: [PATCH] format: rubocop html/document_fragment.rb --- lib/nokogiri/html/document_fragment.rb | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/nokogiri/html/document_fragment.rb b/lib/nokogiri/html/document_fragment.rb index 166ad985e2..ce85cd78e3 100644 --- a/lib/nokogiri/html/document_fragment.rb +++ b/lib/nokogiri/html/document_fragment.rb @@ -4,26 +4,26 @@ module HTML class DocumentFragment < Nokogiri::XML::DocumentFragment #### # Create a Nokogiri::XML::DocumentFragment from +tags+, using +encoding+ - def self.parse tags, encoding = nil + def self.parse(tags, encoding = nil) doc = HTML::Document.new encoding ||= if tags.respond_to?(:encoding) - encoding = tags.encoding - if encoding == ::Encoding::ASCII_8BIT - 'UTF-8' - else - encoding.name - end - else - 'UTF-8' - end + encoding = tags.encoding + if encoding == ::Encoding::ASCII_8BIT + 'UTF-8' + else + encoding.name + end + else + 'UTF-8' + end doc.encoding = encoding new(doc, tags) end - def initialize document, tags = nil, ctx = nil + def initialize(document, tags = nil, ctx = nil) return self unless tags if ctx @@ -33,13 +33,13 @@ def initialize document, tags = nil, ctx = nil self.errors = document.errors - preexisting_errors else # This is a horrible hack, but I don't care - if /^\s*?#{tags}", nil, document.encoding + temp_doc = HTML::Document.parse("#{tags}", nil, document.encoding) temp_doc.xpath(path).each { |child| child.parent = self } self.errors = temp_doc.errors end