1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
module RubyEngine
VERSION = '1.0.1'
@interpreter = case
when RUBY_PLATFORM == 'parrot'
'cardinal'
when Object.const_defined?(:RUBY_ENGINE)
if RUBY_ENGINE == 'ruby'
if RUBY_DESCRIPTION =~ /Enterprise/
'ree'
else
'ruby'
end
else
RUBY_ENGINE.to_s # jruby, rbx, ironruby, macruby, etc.
end
else
'unknown'
end
class << self
def is?(what)
what === @interpreter
end
alias is is?
def to_s
@interpreter.to_s
end
alias inspect to_s
# ask methods
def mri?
RubyEngine.is? 'ruby'
end
alias official_ruby? mri?
alias ruby? mri?
def jruby?
RubyEngine.is? 'jruby'
end
alias java? jruby?
def rubinius?
RubyEngine.is? 'rbx'
end
alias rbx? rubinius?
def ree?
RubyEngine.is? 'ree'
end
alias enterprise? ree?
def ironruby?
RubyEngine.is? 'ironruby'
end
alias iron_ruby? ironruby?
def cardinal?
RubyEngine.is? 'cardinal'
end
alias parrot? cardinal?
alias perl? cardinal?
end
end
# J-_-L
|