Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v0.0.1
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (21 sloc) 0.961 kb

to_source Build Status

to_source is a little Rubinius gem that enables Abstract Syntax Tree nodes to transform themselves into source code. It's the reverse of Rubinius' builtin #to_ast method. See for yourself:

some_code = "a = 123"
ast = some_code.to_ast
# => #<Rubinius::AST::LocalVariableAssignment:0x21b8
        @value=#<Rubinius::AST::FixnumLiteral:0x21bc @value=123 @line=1>
        @variable=nil @line=1 @name=:a>

# => "a = 123"


to_source needs Rubinius 2.0 to run, in either 1.8 or 1.9 mode.

Put this in your Gemfile:

gem 'to_source'

And just call #to_source in any AST node!

Who's this

This was made by Josep M. Bach (Txus) under the MIT license. I'm @txustice on twitter (where you should probably follow me!).

Jump to Line
Something went wrong with that request. Please try again.