Class: SyntaxTree::LabelEnd

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

Overview

LabelEnd represents the end of a dynamic symbol.

{ "key": value }

In the example above, LabelEnd represents the “":” token at the end of the hash key. This node is important for determining the type of quote being used by the label.

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #end_char, #format, #pretty_print, #start_char, #to_json, #to_mermaid

Constructor Details

#initialize(value:, location:) ⇒ LabelEnd

Returns a new instance of LabelEnd.



7107
7108
7109
7110
# File 'lib/syntax_tree/node.rb', line 7107

def initialize(value:, location:)
  @value = value
  @location = location
end

Instance Attribute Details

#valueObject (readonly)

String

the end of the label



7105
7106
7107
# File 'lib/syntax_tree/node.rb', line 7105

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



7133
7134
7135
# File 'lib/syntax_tree/node.rb', line 7133

def ===(other)
  other.is_a?(LabelEnd) && value === other.value
end

#accept(visitor) ⇒ Object



7112
7113
7114
# File 'lib/syntax_tree/node.rb', line 7112

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

#child_nodesObject Also known as: deconstruct



7116
7117
7118
# File 'lib/syntax_tree/node.rb', line 7116

def child_nodes
  []
end

#copy(value: nil, location: nil) ⇒ Object



7120
7121
7122
7123
7124
7125
# File 'lib/syntax_tree/node.rb', line 7120

def copy(value: nil, location: nil)
  LabelEnd.new(
    value: value || self.value,
    location: location || self.location
  )
end

#deconstruct_keys(_keys) ⇒ Object



7129
7130
7131
# File 'lib/syntax_tree/node.rb', line 7129

def deconstruct_keys(_keys)
  { value: value, location: location }
end