Question

When I embed IronRuby what is the proper way to get a reference to either Ruby's DateTime/Date classes or .NET's System.DateTime. I'm running into errors when I try

require 'date'

I get the error - no such file to load -- date

when I try require 'mscorlib.dll' I get the error - no such file to load -- mscorlib.dll

What is the right way to do either of these?

UPDATE: see comments to Jon Skeet

Was it helpful?

Solution

Time is a core type in ruby which maps to a System.DateTime.

To get DateTime.Now you can do Time.new

There are datetime extensions so you could do require 'time' or require 'datetime'

mscorlib is implied and is always required so you don't need to explicitly require it. if you want to get to the CLR DateTime you can do

System::DateTime.now or System::DateTime.Now

OTHER TIPS

Have you tried

require 'mscorlib'

to specify the assembly name instead of the filename? That's what's specified in this old blog post...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top