Class: RubyEngine
- Inherits:
-
Object
- Object
- RubyEngine
- Defined in:
- lib/util/ruby_engine.rb
Overview
Sourced from rbjl.net/35-how-to-properly-check-for-your-ruby-interpreter-version-and-os Extracted from rubyzucker.info/ Copyright © 2010-2013 Jan Lelis <happycode.org> released under the MIT license
Class Method Summary collapse
- .cardinal? ⇒ Boolean (also: parrot?, perl?)
- .interpreter ⇒ Object
- .ironruby? ⇒ Boolean (also: iron_ruby?)
- .is?(what) ⇒ Boolean (also: is)
- .jruby? ⇒ Boolean (also: java?)
- .mri? ⇒ Boolean (also: official_ruby?, ruby?)
- .ree? ⇒ Boolean (also: enterprise?)
- .rubinius? ⇒ Boolean (also: rbx?)
- .to_s ⇒ Object
Class Method Details
.cardinal? ⇒ Boolean Also known as: parrot?, perl?
62 63 64 |
# File 'lib/util/ruby_engine.rb', line 62 def cardinal? RubyEngine.is? 'cardinal' end |
.interpreter ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/util/ruby_engine.rb', line 7 def interpreter case when RUBY_PLATFORM == 'parrot' 'cardinal' when Object.constants.include?( :RUBY_ENGINE ) || Object.constants.include?( 'RUBY_ENGINE' ) if RUBY_ENGINE == 'ruby' if RUBY_DESCRIPTION =~ /Enterprise/ 'ree' else 'mri' end else RUBY_ENGINE.to_s # jruby, rbx, ironruby, macruby, etc. end else # probably 1.8 'mri' end end |
.ironruby? ⇒ Boolean Also known as: iron_ruby?
57 58 59 |
# File 'lib/util/ruby_engine.rb', line 57 def ironruby? RubyEngine.is? 'ironruby' end |
.is?(what) ⇒ Boolean Also known as: is
27 28 29 |
# File 'lib/util/ruby_engine.rb', line 27 def is?(what) what === interpreter end |
.jruby? ⇒ Boolean Also known as: java?
42 43 44 |
# File 'lib/util/ruby_engine.rb', line 42 def jruby? RubyEngine.is? 'jruby' end |
.mri? ⇒ Boolean Also known as: official_ruby?, ruby?
36 37 38 |
# File 'lib/util/ruby_engine.rb', line 36 def mri? RubyEngine.is? 'mri' end |
.ree? ⇒ Boolean Also known as: enterprise?
52 53 54 |
# File 'lib/util/ruby_engine.rb', line 52 def ree? RubyEngine.is? 'ree' end |
.rubinius? ⇒ Boolean Also known as: rbx?
47 48 49 |
# File 'lib/util/ruby_engine.rb', line 47 def rubinius? RubyEngine.is? 'rbx' end |
.to_s ⇒ Object
32 33 34 |
# File 'lib/util/ruby_engine.rb', line 32 def to_s interpreter end |