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=, #next, #next_element, #parent, #previous, #previous_element, #remove, #root_node

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]

18
19
20
21
22
# File 'lib/oga/xml/processing_instruction.rb', line 18

def initialize(options = {})
  super

  @name = options[:name]
end

Instance Attribute Details

#nameString

Returns:

  • (String)

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/oga/xml/processing_instruction.rb', line 9

class ProcessingInstruction < CharacterNode
  attr_accessor :name

  ##
  # @param [Hash] options
  #
  # @option options [String] :name The name of the instruction.
  # @see [Oga::XML::CharacterNode#initialize]
  #
  def initialize(options = {})
    super

    @name = options[:name]
  end

  ##
  # @return [String]
  #
  def to_xml
    return "<?#{name}#{text}?>"
  end

  ##
  # @return [String]
  #
  def inspect
    return "ProcessingInstruction(name: #{name.inspect} text: #{text.inspect})"
  end
end

Instance Method Details

#inspectString

Returns:

  • (String)

34
35
36
# File 'lib/oga/xml/processing_instruction.rb', line 34

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

#to_xmlString

Returns:

  • (String)

27
28
29
# File 'lib/oga/xml/processing_instruction.rb', line 27

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