Module: Drymm::Shapes::ASTMethods

Extended by:
Mix
Included in:
Node
Defined in:
lib/drymm/shapes/ast_methods.rb

Overview

AST-related methods mixin

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#compileObject

Compile an instance back to original object



22
23
24
# File 'lib/drymm/shapes/ast_methods.rb', line 22

def compile
  self.class.compiler.call([to_ast])[0]
end

#to_astArray

Fold data back into the plain AST

Returns:

  • (Array)


11
12
13
14
15
16
# File 'lib/drymm/shapes/ast_methods.rb', line 11

def to_ast
  type, *node = attributes.values_at(*self.class.keys_order)
  node = recursive_ast(node)
  node = node[0] if node.size == 1
  [type, node]
end