I think you should be able to use the RUBY_ENGINE constant for this.