Class: XmlUtils::XMLDecl

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

Instance Attribute Summary collapse

Attributes inherited from ProcessingInstruction

#content, #target

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from ProcessingInstruction

#clone

Methods inherited from ChildNode

#write

Methods inherited from Node

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

Constructor Details

#initialize(version = "1.0", encoding = nil, standalone = nil, parent = nil) ⇒ XMLDecl

Returns a new instance of XMLDecl.



282
283
284
285
286
287
# File 'lib/xmlutils/node.rb', line 282

def initialize(version = "1.0", encoding = nil, standalone = nil, parent = nil)
  super('xml', nil, parent)
  @version = version
  @encoding = encoding
  @standalone = standalone
end

Instance Attribute Details

#encodingObject

Returns the value of attribute encoding.



280
281
282
# File 'lib/xmlutils/node.rb', line 280

def encoding
  @encoding
end

#standaloneObject

Returns the value of attribute standalone.



280
281
282
# File 'lib/xmlutils/node.rb', line 280

def standalone
  @standalone
end

#versionObject

Returns the value of attribute version.



280
281
282
# File 'lib/xmlutils/node.rb', line 280

def version
  @version
end

Instance Method Details

#node_typeObject



289
290
291
# File 'lib/xmlutils/node.rb', line 289

def node_type
  :xmldecl
end

#write_content(output, indent = 0) ⇒ Object



293
294
295
296
297
298
# File 'lib/xmlutils/node.rb', line 293

def write_content(output, indent = 0)
  attrs = ["version=\"#{@version}\""]
  attrs << "encoding=\"#{@encoding}\"" if @encoding
  attrs << "standalone=\"#{@standalone}\"" if @standalone
  output << "<?xml #{attrs.join(' ')}?>"
end