Class: HTML5::TreeBuilders::Hpricot::DocumentType

Inherits:
Node show all
Defined in:
lib/html5/treebuilders/hpricot.rb

Instance Attribute Summary

Attributes inherited from Node

#hpricot

Attributes inherited from Base::Node

#childNodes, #flags, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#appendChild, #hasContent, #insertBefore, #insertText, #removeChild

Methods inherited from Base::Node

#appendChild, #cloneNode, #hasContent, #insertBefore, #insertText, #removeChild, #reparentChildren

Constructor Details

#initialize(name, public_id, system_id) ⇒ DocumentType

Returns a new instance of DocumentType.



156
157
158
# File 'lib/html5/treebuilders/hpricot.rb', line 156

def initialize(name, public_id, system_id)
  @hpricot = self.class.hpricot_class.new(name, public_id, system_id)
end

Class Method Details

.hpricot_classObject



152
153
154
# File 'lib/html5/treebuilders/hpricot.rb', line 152

def self.hpricot_class
  ::Hpricot::DocType
end

Instance Method Details

#printTree(indent = 0) ⇒ Object



160
161
162
163
164
165
166
167
168
# File 'lib/html5/treebuilders/hpricot.rb', line 160

def printTree(indent=0)
  if hpricot.target and hpricot.target.any?
    "\n|#{' ' * indent}<!DOCTYPE #{hpricot.target}" +
      ([hpricot.public_id, hpricot.system_id].any? ? " \"#{hpricot.public_id}\" \"#{hpricot.system_id}\"" : '') +
      '>'
  else
    "\n|#{' ' * indent}<!DOCTYPE >"
  end
end