當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Ruby Specification.required_ruby_version=用法及代碼示例


本文簡要介紹ruby語言中 Gem::Specification.required_ruby_version= 的用法。

用法

required_ruby_version=(req)

此 gem 所需的 Ruby 版本。 ruby 版本可以指定給patch-level:

$ ruby -v -e 'p Gem.ruby_version'
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
#<Gem::Version "2.0.0.247">

也可以指定預發布。

用法:

# This gem will work with 1.8.6 or greater...
spec.required_ruby_version = '>= 1.8.6'

# Only with final releases of major version 2 where minor version is at least 3
spec.required_ruby_version = '~> 2.3'

# Only prereleases or final releases after 2.6.0.preview2
spec.required_ruby_version = '> 2.6.0.preview2'

# This gem will work with 2.3.0 or greater, including major version 3, but lesser than 4.0.0
spec.required_ruby_version = '>= 2.3', '< 4'

相關用法


注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 Specification.required_ruby_version=。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。