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

Constructor Details

#initialize(value:, location:) ⇒ RParen

Returns a new instance of RParen.



9607
9608
9609
9610
# File 'lib/syntax_tree/node.rb', line 9607

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

Instance Attribute Details

#valueObject (readonly)

String

the parenthesis



9605
9606
9607
# File 'lib/syntax_tree/node.rb', line 9605

def value
  @value
end

Instance Method Details

#===(other) ⇒ Object



9633
9634
9635
# File 'lib/syntax_tree/node.rb', line 9633

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

#accept(visitor) ⇒ Object



9612
9613
9614
# File 'lib/syntax_tree/node.rb', line 9612

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

#child_nodesObject Also known as: deconstruct



9616
9617
9618
# File 'lib/syntax_tree/node.rb', line 9616

def child_nodes
  []
end

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



9620
9621
9622
9623
9624
9625
# File 'lib/syntax_tree/node.rb', line 9620

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

#deconstruct_keys(_keys) ⇒ Object



9629
9630
9631
# File 'lib/syntax_tree/node.rb', line 9629

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