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

#next, #node_set, #previous

Instance Method Summary collapse

Methods inherited from Node

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

Methods included from ToXML

#to_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.



12
13
14
15
16
# File 'lib/oga/xml/character_node.rb', line 12

def initialize(options = {})
  super

  @text = options[:text]
end

Instance Attribute Details

#textString

Returns:

  • (String)


7
8
9
# File 'lib/oga/xml/character_node.rb', line 7

def text
  @text
end

Instance Method Details

#inspectString

Returns:

  • (String)


19
20
21
# File 'lib/oga/xml/character_node.rb', line 19

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