Watson1978
12/17/2011 - 11:47 PM

Objective-C + MacRuby

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