Class: Nokogiri::XML::Node
- Inherits:
-
Object
- Object
- Nokogiri::XML::Node
- Defined in:
- lib/epuber/vendor/nokogiri_extensions.rb
Instance Attribute Summary collapse
-
#file_path ⇒ String
Path to original file.
Instance Method Summary collapse
-
#surround_with_element(name, *args, &block) ⇒ Nokogiri::XML::Node
New parent node.
Instance Attribute Details
#file_path ⇒ String
Returns 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.
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 |