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