Class: SyntaxTree::ERB::Doctype

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/erb/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:, closing:, location:) ⇒ Doctype

Returns a new instance of Doctype.



500
501
502
503
504
505
# File 'lib/syntax_tree/erb/nodes.rb', line 500

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

Instance Attribute Details

#closingObject (readonly)

Returns the value of attribute closing.



498
499
500
# File 'lib/syntax_tree/erb/nodes.rb', line 498

def closing
  @closing
end

#locationObject (readonly)

Returns the value of attribute location.



498
499
500
# File 'lib/syntax_tree/erb/nodes.rb', line 498

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



498
499
500
# File 'lib/syntax_tree/erb/nodes.rb', line 498

def name
  @name
end

#openingObject (readonly)

Returns the value of attribute opening.



498
499
500
# File 'lib/syntax_tree/erb/nodes.rb', line 498

def opening
  @opening
end

Instance Method Details

#accept(visitor) ⇒ Object



507
508
509
# File 'lib/syntax_tree/erb/nodes.rb', line 507

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

#child_nodesObject Also known as: deconstruct



511
512
513
# File 'lib/syntax_tree/erb/nodes.rb', line 511

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

#deconstruct_keys(keys) ⇒ Object



517
518
519
# File 'lib/syntax_tree/erb/nodes.rb', line 517

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