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.



5418
5419
5420
5421
5422
# File 'lib/syntax_tree/node.rb', line 5418

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



5416
5417
5418
# File 'lib/syntax_tree/node.rb', line 5416

def comments
  @comments
end

#valueObject (readonly)

String

the left parenthesis



5413
5414
5415
# File 'lib/syntax_tree/node.rb', line 5413

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



5424
5425
5426
# File 'lib/syntax_tree/node.rb', line 5424

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

#child_nodesObject Also known as: deconstruct



5428
5429
5430
# File 'lib/syntax_tree/node.rb', line 5428

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



5434
5435
5436
# File 'lib/syntax_tree/node.rb', line 5434

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

#format(q) ⇒ Object



5438
5439
5440
# File 'lib/syntax_tree/node.rb', line 5438

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