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.



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

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



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

def comments
  @comments
end

#valueObject (readonly)

String

the left bracket



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

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



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

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

#child_nodesObject Also known as: deconstruct



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

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



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

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

#format(q) ⇒ Object



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

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