class SyntaxTree::Symbols
Symbols
represents a symbol array literal with interpolation.
%I[one two three]
Attributes
SymbolsBeg
-
the token that opens this array literal
- Array[
Word
] -
the words in the symbol array literal
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 10646 def initialize(beginning:, elements:, location:) @beginning = beginning @elements = elements @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 10702 def ===(other) other.is_a?(Symbols) && beginning === other.beginning && ArrayMatch.call(elements, other.elements) end
Source
# File lib/syntax_tree/node.rb, line 10653 def accept(visitor) visitor.visit_symbols(self) end
Source
# File lib/syntax_tree/node.rb, line 10657 def child_nodes [] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 10661 def copy(beginning: nil, elements: nil, location: nil) Symbols.new( beginning: beginning || self.beginning, elements: elements || self.elements, location: location || self.location ) end
Source
# File lib/syntax_tree/node.rb, line 10671 def deconstruct_keys(_keys) { beginning: beginning, elements: elements, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 10680 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