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, #format, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:) ⇒ LabelEnd

Returns a new instance of LabelEnd.



6989
6990
6991
6992
# File 'lib/syntax_tree/node.rb', line 6989

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

Instance Attribute Details

#valueObject (readonly)

String

the end of the label



6987
6988
6989
# File 'lib/syntax_tree/node.rb', line 6987

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



7015
7016
7017
# File 'lib/syntax_tree/node.rb', line 7015

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

#accept(visitor) ⇒ Object



6994
6995
6996
# File 'lib/syntax_tree/node.rb', line 6994

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

#child_nodesObject Also known as: deconstruct



6998
6999
7000
# File 'lib/syntax_tree/node.rb', line 6998

def child_nodes
  []
end

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



7002
7003
7004
7005
7006
7007
# File 'lib/syntax_tree/node.rb', line 7002

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

#deconstruct_keys(_keys) ⇒ Object



7011
7012
7013
# File 'lib/syntax_tree/node.rb', line 7011

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