Class: XmlUtils::DocType

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

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(name, external_id = nil, system_id = nil, public_id = nil, parent = nil) ⇒ DocType

Returns a new instance of DocType.



253
254
255
256
257
258
259
260
# File 'lib/xmlutils/node.rb', line 253

def initialize(name, external_id = nil, system_id = nil, public_id = nil, parent = nil)
  super()
  @parent = parent
  @name = name
  @external_id = external_id
  @system_id = system_id
  @public_id = public_id
end

Instance Attribute Details

#external_idObject

Returns the value of attribute external_id.



251
252
253
# File 'lib/xmlutils/node.rb', line 251

def external_id
  @external_id
end

#nameObject

Returns the value of attribute name.



251
252
253
# File 'lib/xmlutils/node.rb', line 251

def name
  @name
end

#public_idObject

Returns the value of attribute public_id.



251
252
253
# File 'lib/xmlutils/node.rb', line 251

def public_id
  @public_id
end

#system_idObject

Returns the value of attribute system_id.



251
252
253
# File 'lib/xmlutils/node.rb', line 251

def system_id
  @system_id
end

Instance Method Details

#node_typeObject



262
263
264
# File 'lib/xmlutils/node.rb', line 262

def node_type
  :doctype
end

#write_content(output, indent = 0) ⇒ Object



266
267
268
269
270
271
272
273
274
275
276
# File 'lib/xmlutils/node.rb', line 266

def write_content(output, indent = 0)
  if @external_id
    if @public_id
      output << "<!DOCTYPE #{@name} PUBLIC \"#{@public_id}\" \"#{@system_id}\">"
    else
      output << "<!DOCTYPE #{@name} SYSTEM \"#{@system_id}\">"
    end
  else
    output << "<!DOCTYPE #{@name}>"
  end
end