Programmatically getting FULL Ruby version?

ぃ、小莉子 提交于 2019-12-09 07:27:10

问题


I know it's possible to get the Ruby version (e.g. "1.9.3") via the RUBY_VERSION constant. However, I want to know how to go about determining the exact version (e.g.: "1.9.3-p0"). The reason is that there is a bug that was not fixed in earlier versions of Ruby 1.9.3 that is working in later versions, and I want some code in a gem I'm working on to account for this.


回答1:


There is a RUBY_PATCHLEVEL constant as well. So you can get your version string as

"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"



回答2:


At least in the newest Ruby (2.3.0), there is also a RUBY_DESCRIPTION constant:

RUBY_DESCRIPTION
# => "ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]"


来源:https://stackoverflow.com/questions/11819525/programmatically-getting-full-ruby-version

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