With::Version
Syntax sugar for version checks. Inspired by usage in hashie.
Usage
Ruby::Version
Use with_minimum_ruby to check against a Ruby version at class load time, instead of runtime.
require 'with-version'
class Example
include With::Version::Ruby
with_minimum_ruby '2.4.0' do
# only declared with Ruby 2.4.0 or newer
def dig(*keys)
puts "Digging #{keys.join(', ')} ..."
end
end
end
# Ruby 2.3.0
undefined method `dig' for #<Example:0x00007fca9388a8a0> (NoMethodError)
# Ruby 2.4.0
Digging x, y ...
Contributing
You're encouraged to contribute to this gem. See CONTRIBUTING for details.
Copyright and License
Copyright (c) 2020, Daniel Doubrovkine and Contributors.
This project is licensed under the MIT License.