Class: SyntaxTree::QSymbolsBeg

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

Overview

QSymbolsBeg represents the beginning of a symbol literal array.

%i[one two three]

In the snippet above, QSymbolsBeg represents the “%i[” token. Note that these kinds of arrays can start with a lot of different delimiter types (e.g., %i| or %i<).

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#format, #to_json

Constructor Details

#initialize(value:, location:) ⇒ QSymbolsBeg

Returns a new instance of QSymbolsBeg.



6365
6366
6367
6368
# File 'lib/syntax_tree/node.rb', line 6365

def initialize(value:, location:)
  @value = value
  @location = location
end

Instance Attribute Details

#valueObject (readonly)

String

the beginning of the array literal



6363
6364
6365
# File 'lib/syntax_tree/node.rb', line 6363

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



6370
6371
6372
# File 'lib/syntax_tree/node.rb', line 6370

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

#child_nodesObject Also known as: deconstruct



6374
6375
6376
# File 'lib/syntax_tree/node.rb', line 6374

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



6380
6381
6382
# File 'lib/syntax_tree/node.rb', line 6380

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

#pretty_print(q) ⇒ Object



6384
6385
6386
6387
6388
6389
6390
6391
# File 'lib/syntax_tree/node.rb', line 6384

def pretty_print(q)
  q.group(2, "(", ")") do
    q.text("qsymbols_beg")

    q.breakable
    q.pp(value)
  end
end