Skip to content

Instantly share code, notes, and snippets.

@Asher-
Created January 9, 2012 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Asher-/1581495 to your computer and use it in GitHub Desktop.
Save Asher-/1581495 to your computer and use it in GitHub Desktop.
Embedding Ruby 1.9 in C
#include <ruby.h>
#include <unistd.h>
int main( int argc __attribute__((unused)), char *argv[] __attribute__((unused)) ) {
ruby_init();
// Change working directory to script
chdir( "/Users/ahaig/Sites/rpdom" );
// Ruby Options are just like /usr/bin/ruby
// interpreter name, script name, argv ...
char* options[] = { "", "rpdom_test.rb", };
void* node = ruby_options( 2, options );
return ruby_run_node( node );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment