Class: SyntaxTree::XML::Element::OpeningTag

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

Overview

The opening tag of an element. It contains the opening character (<), the name of the element, any optional attributes, and the closing token (either > or />).

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(opening:, name:, attributes:, closing:, location:) ⇒ OpeningTag



225
226
227
228
229
230
231
# File 'lib/syntax_tree/xml/nodes.rb', line 225

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



223
224
225
# File 'lib/syntax_tree/xml/nodes.rb', line 223

def attributes
  @attributes
end

#closingObject (readonly)

Returns the value of attribute closing.



223
224
225
# File 'lib/syntax_tree/xml/nodes.rb', line 223

def closing
  @closing
end

#locationObject (readonly)

Returns the value of attribute location.



223
224
225
# File 'lib/syntax_tree/xml/nodes.rb', line 223

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



223
224
225
# File 'lib/syntax_tree/xml/nodes.rb', line 223

def name
  @name
end

#openingObject (readonly)

Returns the value of attribute opening.



223
224
225
# File 'lib/syntax_tree/xml/nodes.rb', line 223

def opening
  @opening
end

Instance Method Details

#accept(visitor) ⇒ Object



233
234
235
# File 'lib/syntax_tree/xml/nodes.rb', line 233

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

#child_nodesObject Also known as: deconstruct



237
238
239
# File 'lib/syntax_tree/xml/nodes.rb', line 237

def child_nodes
  [opening, name, *attributes, closing]
end

#deconstruct_keys(keys) ⇒ Object



243
244
245
246
247
248
249
250
251
# File 'lib/syntax_tree/xml/nodes.rb', line 243

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