Class: SyntaxTree::LBrace

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

Overview

LBrace represents the use of a left brace, i.e., {.

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

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

Returns a new instance of LBrace.



6309
6310
6311
6312
6313
# File 'lib/syntax_tree/node.rb', line 6309

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



6307
6308
6309
# File 'lib/syntax_tree/node.rb', line 6307

def comments
  @comments
end

#valueObject (readonly)

String

the left brace



6304
6305
6306
# File 'lib/syntax_tree/node.rb', line 6304

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



6315
6316
6317
# File 'lib/syntax_tree/node.rb', line 6315

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

#child_nodesObject Also known as: deconstruct



6319
6320
6321
# File 'lib/syntax_tree/node.rb', line 6319

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



6325
6326
6327
# File 'lib/syntax_tree/node.rb', line 6325

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

#format(q) ⇒ Object



6329
6330
6331
# File 'lib/syntax_tree/node.rb', line 6329

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