Class: Nokogiri::XML::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/epuber/vendor/nokogiri_extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#file_pathString

Returns path to original file.

Returns:

  • (String)

    path to original file



30
31
32
# File 'lib/epuber/vendor/nokogiri_extensions.rb', line 30

def file_path
  @file_path
end

Instance Method Details

#surround_with_element(name, *args, &block) ⇒ Nokogiri::XML::Node

Returns new parent node.

Parameters:

  • name (String)
  • args (Hash, String)

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/epuber/vendor/nokogiri_extensions.rb', line 13

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