Class: SyntaxTree::RBracket

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

Overview

RBracket represents the use of a right bracket, i.e., ].

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:) ⇒ RBracket

Returns a new instance of RBracket.



8937
8938
8939
8940
# File 'lib/syntax_tree/node.rb', line 8937

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

Instance Attribute Details

#valueObject (readonly)

String

the right bracket



8935
8936
8937
# File 'lib/syntax_tree/node.rb', line 8935

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



8963
8964
8965
# File 'lib/syntax_tree/node.rb', line 8963

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

#accept(visitor) ⇒ Object



8942
8943
8944
# File 'lib/syntax_tree/node.rb', line 8942

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

#child_nodesObject Also known as: deconstruct



8946
8947
8948
# File 'lib/syntax_tree/node.rb', line 8946

def child_nodes
  []
end

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



8950
8951
8952
8953
8954
8955
# File 'lib/syntax_tree/node.rb', line 8950

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

#deconstruct_keys(_keys) ⇒ Object



8959
8960
8961
# File 'lib/syntax_tree/node.rb', line 8959

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