Class: SyntaxTree::LBracket

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

Overview

LBracket represents the use of a left bracket, 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: []) ⇒ LBracket

Returns a new instance of LBracket.



5909
5910
5911
5912
5913
# File 'lib/syntax_tree/node.rb', line 5909

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



5907
5908
5909
# File 'lib/syntax_tree/node.rb', line 5907

def comments
  @comments
end

#valueObject (readonly)

String

the left bracket



5904
5905
5906
# File 'lib/syntax_tree/node.rb', line 5904

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



5915
5916
5917
# File 'lib/syntax_tree/node.rb', line 5915

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

#child_nodesObject Also known as: deconstruct



5919
5920
5921
# File 'lib/syntax_tree/node.rb', line 5919

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



5925
5926
5927
# File 'lib/syntax_tree/node.rb', line 5925

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

#format(q) ⇒ Object



5929
5930
5931
# File 'lib/syntax_tree/node.rb', line 5929

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