Retrieving accessors in IronRuby
- by rsteckly
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");