aboutsummaryrefslogtreecommitdiffhomepage
path: root/content/posts/2021-10-02/ruby-detect-running-implementation.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/2021-10-02/ruby-detect-running-implementation.adoc')
-rw-r--r--content/posts/2021-10-02/ruby-detect-running-implementation.adoc72
1 files changed, 0 insertions, 72 deletions
diff --git a/content/posts/2021-10-02/ruby-detect-running-implementation.adoc b/content/posts/2021-10-02/ruby-detect-running-implementation.adoc
deleted file mode 100644
index 1434891..0000000
--- a/content/posts/2021-10-02/ruby-detect-running-implementation.adoc
+++ /dev/null
@@ -1,72 +0,0 @@
-= [Ruby] 自身を実行している処理系の種類を判定する
-:tags: ruby
-:description: Ruby には複数の実装があるが、自身を実行している処理系の種類を \
- スクリプト上からどのように判定すればよいだろうか。
-:revision-1: 2021-10-02 Qiita から移植
-
-この記事は Qiita から移植してきたものです。 元 URL:
-https://qiita.com/nsfisis/items/74d7ffeeebc51b20d791
-
-'''''
-
-Ruby
-という言語には複数の実装があるが、それらをスクリプト上からどのようにして
-programmatically に見分ければよいだろうか。
-
-`Object` クラスに定義されている `RUBY_ENGINE`
-という定数がこの用途に使える。
-
-参考:
-https://docs.ruby-lang.org/ja/latest/method/Object/c/RUBY_ENGINE.html[Object::RUBY_ENGINE]
-
-上記ページの例から引用する:
-
-[source,shell-session]
-----
-$ ruby-1.9.1 -ve 'p RUBY_ENGINE'
-ruby 1.9.1p0 (2009-03-04 revision 22762) [x86_64-linux]
-"ruby"
-$ jruby -ve 'p RUBY_ENGINE'
-jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-03-16 rev 9419) [i386-java]
-"jruby"
-----
-
-それぞれの処理系がどのような値を返すかだが、stack overflow
-に良い質問と回答があった。
-
-https://stackoverflow.com/a/9894232[What values for RUBY_ENGINE
-correspond to which Ruby implementations?] より引用:
-
-____
-[cols="^,<",options="header",]
-|===
-|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
-|===
-____
-
-なお、この質問・回答は
-2014年になされたものであり、値は変わっている可能性がある。MRI (aka
-CRuby) については執筆時現在 (2020/12/8) も `'ruby'`
-が返ってくることを確認済み。
-
-この表にない主要な処理系として、https://mruby.org[mruby] は `'mruby'`
-を返す。
-
-https://github.com/mruby/mruby/blob/ed29d74bfd95362eaeb946fcf7e865d80346b62b/include/mruby/version.h#L32-L35[mruby
-該当部分のソース] より引用:
-
-[source,c]
-----
-/*
- * Ruby engine.
- */
-#define MRUBY_RUBY_ENGINE "mruby"
-----