Class: Oga::XML::CharacterNode

Inherits:
Node
  • Object
show all
Defined in:
lib/oga/xml/character_node.rb

Overview

Base class for nodes that represent a text-like value such as Text and Comment nodes.

Direct Known Subclasses

Cdata, Comment, ProcessingInstruction, Text

Instance Attribute Summary collapse

Attributes inherited from Node

#node_set

Instance Method Summary collapse

Methods inherited from Node

#after, #before, #children, #children=, #html?, #next, #next_element, #parent, #previous, #previous_element, #remove, #replace, #root_node, #xml?

Methods included from Traversal

#each_node

Constructor Details

#initialize(options = {}) ⇒ CharacterNode

Returns a new instance of CharacterNode.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :text (String)

    The text of the node.



16
17
18
19
20
# File 'lib/oga/xml/character_node.rb', line 16

def initialize(options = {})
  super

  @text = options[:text]
end

Instance Attribute Details

#textString

Returns:

  • (String)


9
10
11
# File 'lib/oga/xml/character_node.rb', line 9

def text
  @text
end

Instance Method Details

#inspectString

Returns:

  • (String)


32
33
34
# File 'lib/oga/xml/character_node.rb', line 32

def inspect
  "#{self.class.to_s.split('::').last}(#{text.inspect})"
end

#to_xmlString

Returns:

  • (String)


25
26
27
# File 'lib/oga/xml/character_node.rb', line 25

def to_xml
  text.to_s
end