Created
July 20, 2014 22:50
-
-
Save teliosdev/588282404222eb22fab3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Liquidscript | |
module AST | |
class Node | |
class << self | |
# Define a child node for this node. It accepts a name. | |
# | |
# @param name [Symbol] the name of the child. | |
# @return [void] | |
def child(name) | |
children << name | |
attr_accessor(name) | |
end | |
# Return an array of the children of this node. | |
# | |
# @return [Array<Symbol>] | |
def children | |
@_children ||= [] | |
end | |
end | |
# Return an array of all of the children of this node. | |
# | |
# @return [Array<Node>] | |
def children | |
self.class.children.map { |child| send(child) } | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment