Class: Emcee::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/emcee/node.rb

Overview

Document is responsible for interacting with individual html nodes that make up the parsed document.

Instance Method Summary collapse

Constructor Details

#initialize(parser_node) ⇒ Node

Returns a new instance of Node.



5
6
7
# File 'lib/emcee/node.rb', line 5

def initialize(parser_node)
  @parser_node = parser_node
end

Instance Method Details

#pathObject



9
10
11
# File 'lib/emcee/node.rb', line 9

def path
  href || src
end

#removeObject



13
14
15
# File 'lib/emcee/node.rb', line 13

def remove
  @parser_node.remove
end

#replace(type, new_content) ⇒ Object



17
18
19
20
21
# File 'lib/emcee/node.rb', line 17

def replace(type, new_content)
  new_node = Nokogiri::XML::Node.new(type, document)
  new_node.content = new_content
  @parser_node.replace(new_node)
end