Ruby 1.9.3 Teeny Version

早过忘川 提交于 2019-12-01 22:18:58

Ruby has two concepts of version: The actual release version, and the "compatibility version". For all Rubies 1.9.1 -> 1.9.3, the compatibility version is 1.9.1, because they are all backward compatible with the 1.9.1 release.

The RUBY_VERSIONconstant contains the release version number, but you will need to split the dots to get the MAJOR, MINOR, and TEENY if those values are important to you:

>> major, minor, teeny = RUBY_VERSION.split(".")
=> ["1", "9", "3"]
>> teeny
=> "3"

That said, Ruby version numbers are specifically designed to be ASCII-comparable, so it is common to see code like this for simple version checks:

if RUBY_VERSION >= "1.9.3"
  #...
end

Patch level can typically be ignored, because there are no API changes in patch level releases, only bug fixes and security patches. Hope that helps!

Looks like Minor is just reporting on the library minor - ok. So all I am left with is the ruby_version string - better than nothing.

# /usr/bin/ruby -rrbconfig -e 'print RbConfig::CONFIG.fetch(%q(LIBRUBY_SO))'
libruby.so.1.9.1
# /usr/bin/ruby -rrbconfig -e 'print RbConfig::CONFIG.fetch(%q(ruby_version))'
1.9.3-p286

ruby 1.8 shows this:

$ /usr/bin/ruby -rrbconfig -e 'print RbConfig::CONFIG.fetch(%q(LIBRUBY_SO))'
libruby1.8.so.1.8.7

and ruby 1.9.2-p320 this:

$ ruby -rrbconfig -e 'print RbConfig::CONFIG.fetch(%q(LIBRUBY_SO))'
libruby.so.1.9.1

So I guess mystery solved.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!