Skip to content

Instantly share code, notes, and snippets.

@seanlilmateus
Forked from Watson1978/objc-macruby.m
Created December 18, 2011 08:55
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 seanlilmateus/1492772 to your computer and use it in GitHub Desktop.
Save seanlilmateus/1492772 to your computer and use it in GitHub Desktop.
Objective-C + MacRuby
#import <Foundation/Foundation.h>
#import <MacRuby/MacRuby.h>
int main(void)
{
id ruby;
id foo;
ruby = [[MacRuby sharedRuntime] evaluateFileAtPath:@"test.rb"];
foo = [ruby performRubySelector:@selector(main:) withArguments:@"from Objc", NULL];
NSLog(@"%@", foo);
NSLog(@"%@", [foo hello]);
}
def main(str)
Foo.new(str)
end
class Foo
def initialize(str = "")
@str = str.to_s
end
def hello
"Hello, MacRuby #{@str}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment