Class: Oga::XML::ProcessingInstruction

Inherits:
CharacterNode show all
Defined in:
lib/oga/xml/processing_instruction.rb

Overview

Class used for storing information about a single processing instruction.

Instance Attribute Summary collapse

Attributes inherited from CharacterNode

#text

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 = {}) ⇒ ProcessingInstruction

Returns a new instance of ProcessingInstruction.

Parameters:

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

Options Hash (options):

  • :name (String)

    The name of the instruction.

See Also:

  • Oga::XML::ProcessingInstruction.[Oga[Oga::XML[Oga::XML::CharacterNode[Oga::XML::CharacterNode#initialize]


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

def initialize(options = {})
  super

  @name = options[:name]
end

Instance Attribute Details

#nameString

Returns:

  • (String)


8
9
10
# File 'lib/oga/xml/processing_instruction.rb', line 8

def name
  @name
end

Instance Method Details

#inspectString

Returns:

  • (String)


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

def inspect
  "ProcessingInstruction(name: #{name.inspect} text: #{text.inspect})"
end

#to_xmlString

Returns:

  • (String)


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

def to_xml
  "<?#{name}#{text}?>"
end