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

Constructor Details

#initialize(value:, location:) ⇒ RBracket



8872
8873
8874
8875
# File 'lib/syntax_tree/node.rb', line 8872

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

Instance Attribute Details

#valueObject (readonly)

String

the right bracket



8870
8871
8872
# File 'lib/syntax_tree/node.rb', line 8870

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



8898
8899
8900
# File 'lib/syntax_tree/node.rb', line 8898

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

#accept(visitor) ⇒ Object



8877
8878
8879
# File 'lib/syntax_tree/node.rb', line 8877

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

#child_nodesObject Also known as: deconstruct



8881
8882
8883
# File 'lib/syntax_tree/node.rb', line 8881

def child_nodes
  []
end

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



8885
8886
8887
8888
8889
8890
# File 'lib/syntax_tree/node.rb', line 8885

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

#deconstruct_keys(_keys) ⇒ Object



8894
8895
8896
# File 'lib/syntax_tree/node.rb', line 8894

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