lib/furnace/ast/node.rb in furnace-0.3.1 vs lib/furnace/ast/node.rb in furnace-0.4.0.beta.1
- old
+ new
@@ -128,9 +128,23 @@
# @return [String]
def to_s
"(#{fancy_type} ...)"
end
+ # Returns {#children}. This is very useful in order to decompose nodes
+ # concisely. For example:
+ #
+ # node = s(:gasgn, :$foo, s(:integer, 1))
+ # s
+ # var_name, value = *node
+ # p var_name # => :$foo
+ # p value # => (integer 1)
+ #
+ # @return [Array]
+ def to_a
+ children
+ end
+
# Converts `self` to a pretty-printed s-expression.
#
# @param [Integer] indent Base indentation level.
# @return [String]
def to_sexp(indent=0)
\ No newline at end of file