我知道在运行时检测 Ruby实现(例如,MRI、JRuby、Rubinius 等)的方法是检查全局常量RUBY_ENGINE
:
$ ruby -e 'puts RUBY_ENGINE'
ruby
什么是已知的 Ruby 实现及其对应的 RUBY_ENGINE 值的相当全面的列表?
这是我到目前为止发现的:
| RUBY_ENGINE | Implementation |
|:-----------:|:------------------|
| <undefined> | MRI < 1.9 |
| 'ruby' | MRI >= 1.9 or REE |
| 'jruby' | JRuby |
| 'macruby' | MacRuby |
| 'rbx' | Rubinius |
| 'maglev' | MagLev |
| 'ironruby' | IronRuby |
| 'cardinal' | Cardinal |
上述 Ruby 实现的链接:
支持 Ujihisa 为这个具有最大价值的博客条目。通过阅读this和this发现了其他人。从 StackOverflow 上的其他答案中收集了更多价值。给所有贡献的人更多的道具!
还:
| RUBY_ENGINE | Implementation |
|:-----------:|:------------------|
| "ruby" | REE |
| "maglev" | MagLev |