Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Forked from kyab/objc-macruby.m
Created December 18, 2011 11:24

Revisions

  1. @kyab kyab revised this gist Dec 18, 2011. 2 changed files with 4 additions and 6 deletions.
    7 changes: 4 additions & 3 deletions objc-macruby.m
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,12 @@

    int main(void)
    {
    id ruby;
    id fooClass;
    id foo;

    ruby = [[MacRuby sharedRuntime] evaluateFileAtPath:@"test.rb"];
    foo = [ruby performRubySelector:@selector(main:) withArguments:@"from Objc", NULL];
    [[MacRuby sharedRuntime] evaluateFileAtPath:@"test.rb"];
    fooClass = [[MacRuby sharedRuntime] evaluateString:@"Foo"];
    foo = [fooClass performRubySelector:@selector(new) withArguments:@"from Objc", NULL];
    NSLog(@"%@", foo);
    NSLog(@"%@", [foo hello]);
    }
    3 changes: 0 additions & 3 deletions test.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,3 @@
    def main(str)
    Foo.new(str)
    end

    class Foo
    def initialize(str = "")
  2. Watson1978 created this gist Dec 17, 2011.
    13 changes: 13 additions & 0 deletions objc-macruby.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #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]);
    }
    13 changes: 13 additions & 0 deletions test.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    def main(str)
    Foo.new(str)
    end

    class Foo
    def initialize(str = "")
    @str = str.to_s
    end

    def hello
    "Hello, MacRuby #{@str}"
    end
    end