Class: SyntaxTree::LParen

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

Overview

LParen represents the use of a left parenthesis, i.e., (.

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ LParen

Returns a new instance of LParen.



5941
5942
5943
5944
5945
# File 'lib/syntax_tree/node.rb', line 5941

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



5939
5940
5941
# File 'lib/syntax_tree/node.rb', line 5939

def comments
  @comments
end

#valueObject (readonly)

String

the left parenthesis



5936
5937
5938
# File 'lib/syntax_tree/node.rb', line 5936

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



5947
5948
5949
# File 'lib/syntax_tree/node.rb', line 5947

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

#child_nodesObject Also known as: deconstruct



5951
5952
5953
# File 'lib/syntax_tree/node.rb', line 5951

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



5957
5958
5959
# File 'lib/syntax_tree/node.rb', line 5957

def deconstruct_keys(keys)
  { value: value, location: location, comments: comments }
end

#format(q) ⇒ Object



5961
5962
5963
# File 'lib/syntax_tree/node.rb', line 5961

def format(q)
  q.text(value)
end