Method: Gem.ruby_version

Defined in:
lib/rubygems.rb

.ruby_versionObject

A Gem::Version for the currently running Ruby.



861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
# File 'lib/rubygems.rb', line 861

def self.ruby_version
  return @ruby_version if defined? @ruby_version
  version = RUBY_VERSION.dup

  if RUBY_PATCHLEVEL == -1
    if RUBY_ENGINE == "ruby"
      desc = RUBY_DESCRIPTION[/\Aruby #{Regexp.quote(RUBY_VERSION)}([^ ]+) /, 1]
    else
      desc = RUBY_DESCRIPTION[/\A#{RUBY_ENGINE} #{Regexp.quote(RUBY_ENGINE_VERSION)} \(#{RUBY_VERSION}([^ ]+)\) /, 1]
    end
    version << ".#{desc}" if desc
  end

  @ruby_version = Gem::Version.new version
end