The method I know of to detect the Ruby implementation (e.g., MRI, JRuby, Rubinius, etc.) at run time is to check the global constant RUBY_ENGINE
:
$ ruby -e 'puts RUBY_ENGINE'
ruby
What's a reasonably comprehensive list of known Ruby implementations and their corresponding values for RUBY_ENGINE?