Created
January 9, 2012 06:35
-
-
Save Asher-/1581495 to your computer and use it in GitHub Desktop.
Embedding Ruby 1.9 in C
This file contains 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
#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