class SyntaxTree::QSymbols
QSymbols
represents a symbol literal array without interpolation.
%i[one two three]
Attributes
QSymbolsBeg
-
the token that opens this array literal
- Array[
TStringContent
] -
the elements of the array
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 8682 def initialize(beginning:, elements:, location:) @beginning = beginning @elements = elements @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 8742 def ===(other) other.is_a?(QSymbols) && beginning === other.beginning && ArrayMatch.call(elements, other.elements) end
Source
# File lib/syntax_tree/node.rb, line 8689 def accept(visitor) visitor.visit_qsymbols(self) end
Source
# File lib/syntax_tree/node.rb, line 8693 def child_nodes [] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 8697 def copy(beginning: nil, elements: nil, location: nil) node = QSymbols.new( beginning: beginning || self.beginning, elements: elements || self.elements, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
Source
# File lib/syntax_tree/node.rb, line 8711 def deconstruct_keys(_keys) { beginning: beginning, elements: elements, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 8720 def format(q) opening, closing = "%i[", "]" if elements.any? { |element| element.match?(/[\[\]]/) } opening = beginning.value closing = Quotes.matching(opening[2]) end q.text(opening) q.group do q.indent do q.breakable_empty q.seplist( elements, ArrayLiteral::BREAKABLE_SPACE_SEPARATOR ) { |element| q.format(element) } end q.breakable_empty end q.text(closing) end