Class: SyntaxTree::XML::DocType

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/xml/nodes.rb

Overview

A document type declaration is a special kind of tag that specifies the type of the document. It contains an opening declaration, the name of the document type, an optional external identifier, and a closing of the tag.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(opening:, name:, external_id:, closing:, location:) ⇒ DocType



152
153
154
155
156
157
158
# File 'lib/syntax_tree/xml/nodes.rb', line 152

def initialize(opening:, name:, external_id:, closing:, location:)
  @opening = opening
  @name = name
  @external_id = external_id
  @closing = closing
  @location = location
end

Instance Attribute Details

#closingObject (readonly)

Returns the value of attribute closing.



150
151
152
# File 'lib/syntax_tree/xml/nodes.rb', line 150

def closing
  @closing
end

#external_idObject (readonly)

Returns the value of attribute external_id.



150
151
152
# File 'lib/syntax_tree/xml/nodes.rb', line 150

def external_id
  @external_id
end

#locationObject (readonly)

Returns the value of attribute location.



150
151
152
# File 'lib/syntax_tree/xml/nodes.rb', line 150

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



150
151
152
# File 'lib/syntax_tree/xml/nodes.rb', line 150

def name
  @name
end

#openingObject (readonly)

Returns the value of attribute opening.



150
151
152
# File 'lib/syntax_tree/xml/nodes.rb', line 150

def opening
  @opening
end

Instance Method Details

#accept(visitor) ⇒ Object



160
161
162
# File 'lib/syntax_tree/xml/nodes.rb', line 160

def accept(visitor)
  visitor.visit_doctype(self)
end

#child_nodesObject Also known as: deconstruct



164
165
166
# File 'lib/syntax_tree/xml/nodes.rb', line 164

def child_nodes
  [opening, name, external_id, closing].compact
end

#deconstruct_keys(keys) ⇒ Object



170
171
172
173
174
175
176
177
178
# File 'lib/syntax_tree/xml/nodes.rb', line 170

def deconstruct_keys(keys)
  {
    opening: opening,
    name: name,
    external_id: external_id,
    closing: closing,
    location: location
  }
end