Method: AST::Node#to_sexp_array

Defined in:
lib/ast/node.rb

#to_sexp_arrayArray<Symbol, [...Array]>

Converts self to an Array where the first element is the type as a Symbol, and subsequent elements are the same representation of its children.

Returns:

  • (Array<Symbol, [...Array]>)


237
238
239
240
241
242
243
244
245
246
247
# File 'lib/ast/node.rb', line 237

def to_sexp_array
  children_sexp_arrs = children.map do |child|
    if child.is_a?(Node)
      child.to_sexp_array
    else
      child
    end
  end

  [type, *children_sexp_arrs]
end