Class: XmlUtils::ProcessingInstruction

Inherits:
ChildNode show all
Defined in:
lib/xmlutils/node.rb

Direct Known Subclasses

XMLDecl

Instance Attribute Summary collapse

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from ChildNode

#write

Methods inherited from Node

#deep_clone, #document, #each, #next_sibling, #previous_sibling, #remove, #root, #to_s

Constructor Details

#initialize(target, content = nil, parent = nil) ⇒ ProcessingInstruction

Returns a new instance of ProcessingInstruction.



226
227
228
229
230
231
# File 'lib/xmlutils/node.rb', line 226

def initialize(target, content = nil, parent = nil)
  super()
  @parent = parent
  @target = target
  @content = content
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



224
225
226
# File 'lib/xmlutils/node.rb', line 224

def content
  @content
end

#targetObject

Returns the value of attribute target.



224
225
226
# File 'lib/xmlutils/node.rb', line 224

def target
  @target
end

Instance Method Details

#cloneObject



237
238
239
# File 'lib/xmlutils/node.rb', line 237

def clone
  ProcessingInstruction.new(@target, @content)
end

#node_typeObject



233
234
235
# File 'lib/xmlutils/node.rb', line 233

def node_type
  :processing_instruction
end

#write_content(output, indent = 0) ⇒ Object



241
242
243
244
245
246
247
# File 'lib/xmlutils/node.rb', line 241

def write_content(output, indent = 0)
  if @content && !@content.empty?
    output << "<?#{@target} #{@content}?>"
  else
    output << "<?#{@target}?>"
  end
end