Class: SyntaxTree::ERB::Doctype

Inherits:
Element 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

Attributes inherited from Element

#location, #new_line

Instance Method Summary collapse

Methods inherited from Element

#without_new_line

Methods inherited from Node

#format, #pretty_print, #skip?, #without_new_line

Constructor Details

#initialize(opening:, name:, closing:, new_line:, location:) ⇒ Doctype

Returns a new instance of Doctype.



702
703
704
705
706
707
# File 'lib/syntax_tree/erb/nodes.rb', line 702

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

Instance Attribute Details

#closingObject (readonly)

Returns the value of attribute closing.



700
701
702
# File 'lib/syntax_tree/erb/nodes.rb', line 700

def closing
  @closing
end

#nameObject (readonly)

Returns the value of attribute name.



700
701
702
# File 'lib/syntax_tree/erb/nodes.rb', line 700

def name
  @name
end

#openingObject (readonly)

Returns the value of attribute opening.



700
701
702
# File 'lib/syntax_tree/erb/nodes.rb', line 700

def opening
  @opening
end

Instance Method Details

#accept(visitor) ⇒ Object



709
710
711
# File 'lib/syntax_tree/erb/nodes.rb', line 709

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

#child_nodesObject Also known as: deconstruct



713
714
715
# File 'lib/syntax_tree/erb/nodes.rb', line 713

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

#deconstruct_keys(keys) ⇒ Object



719
720
721
# File 'lib/syntax_tree/erb/nodes.rb', line 719

def deconstruct_keys(keys)
  super.merge(opening: opening, name: name, closing: closing)
end