Sha256: 8c7a7c79f9e0fa5d7ebeb50cf8d9efb25b73ba7d58a663ea56738ae515188a01

Contents?: true

Size: 706 Bytes

Versions: 15

Compression:

Stored size: 706 Bytes

Contents

# frozen_string_literal: true

require 'nokogiri'

module Nokogiri
  module XML
    class Node
      # @param [String] name
      # @param [Hash, String] args
      #
      # @return [Nokogiri::XML::Node] new parent node
      #
      def surround_with_element(name, *args, &block)
        new_parent = document.create_element(name, *args, &block)
        old_parent = parent

        self.parent = new_parent

        if old_parent.is_a?(Nokogiri::XML::Document)
          old_parent.root = new_parent
        else
          old_parent.children = new_parent
        end

        new_parent
      end

      # @return [String] path to original file
      #
      attr_accessor :file_path
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
epuber-0.11.1 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.11.0 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.10.3 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.10.2 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.10.1 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.9.3 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.9.2 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.9.1 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.9.0 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.8.0 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.7.4 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.7.3 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.7.2 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.7.1 lib/epuber/vendor/nokogiri_extensions.rb
epuber-0.7.0 lib/epuber/vendor/nokogiri_extensions.rb