Class: SyntaxTree::RParen

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

Overview

RParen represents the use of a right parenthesis, 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:) ⇒ RParen

Returns a new instance of RParen.



9707
9708
9709
9710
# File 'lib/syntax_tree/node.rb', line 9707

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

Instance Attribute Details

#valueObject (readonly)

String

the parenthesis



9705
9706
9707
# File 'lib/syntax_tree/node.rb', line 9705

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



9733
9734
9735
# File 'lib/syntax_tree/node.rb', line 9733

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

#accept(visitor) ⇒ Object



9712
9713
9714
# File 'lib/syntax_tree/node.rb', line 9712

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

#child_nodesObject Also known as: deconstruct



9716
9717
9718
# File 'lib/syntax_tree/node.rb', line 9716

def child_nodes
  []
end

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



9720
9721
9722
9723
9724
9725
# File 'lib/syntax_tree/node.rb', line 9720

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

#deconstruct_keys(_keys) ⇒ Object



9729
9730
9731
# File 'lib/syntax_tree/node.rb', line 9729

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