MrEvil
MrEvil

Reputation: 8073

Writing a wrapper that uses FFI when on MRI and Java when on JRuby

I need to wrap a new library for use by Ruby. The plan was to detect which implementation of Ruby is in use, and load a C library via FFI if on MRI, and wrap a Java lib if using JRuby.

I'm having trouble finding docs, so any pointer would be helpful. I know there are other libraries that do this, but I can't find one at the moment, so if you know of any gem that does this that would also be helpful. Thanks.

Upvotes: 0

Views: 152

Answers (1)

pje
pje

Reputation: 22707

To start, you can inspect the value of the RUBY_ENGINE constant at runtime.

Running under MRI (1.9.x), it'll be "ruby". Under JRuby, "jruby".

Upvotes: 2

Related Questions