Retrieving accessors in IronRuby

Posted by rsteckly on Stack Overflow See other posts from Stack Overflow or by rsteckly
Published on 2010-04-14T20:28:17Z Indexed on 2010/04/17 15:43 UTC
Read the original article Hit count: 325

Filed under:

I'm trying to figure out how to retrieve the value stored in the Person class. The problem is just that after I define an instance of the Person class, I don't know how to retrieve it within the IronRuby code because the instance name is in the .NET part.

 /*class Person
        attr_accessor :name

                def initialize(strname)
                    self.name=strname
                end
    end*/

    //We start the DLR, in this case starting the Ruby version


 ScriptEngine engine = IronRuby.Ruby.CreateEngine();
        ScriptScope scope = engine.ExecuteFile("c:\\Users\\ron\\RubymineProjects\\untitled\\person.rb");

    //We get the class type
    object person = engine.Runtime.Globals.GetVariable("Person");

    //We create an instance
    object marcy = engine.Operations.CreateInstance(person, "marcy");

© Stack Overflow or respective owner

Related posts about ironruby