123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Cop::TargetRubyVersion

Overview

Common functionality for checking target ruby version.

Instance Method Summary

Instance Method Details

#maximum_target_ruby_version(version)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 19

def maximum_target_ruby_version(version)
  @maximum_target_ruby_version = version
end

#minimum_target_ruby_version(version)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 15

def minimum_target_ruby_version(version)
  @minimum_target_ruby_version = version
end

#required_maximum_ruby_version

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 11

def required_maximum_ruby_version
  @maximum_target_ruby_version
end

#required_minimum_ruby_version

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 7

def required_minimum_ruby_version
  @minimum_target_ruby_version
end

#support_target_ruby_version?(version) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 23

def support_target_ruby_version?(version)
  # By default, no minimum or maximum versions of ruby are required
  # to run any cop. In order to do a simple numerical comparison of
  # the requested version against any requirements, we use 0 and
  # Infinity as the default values to indicate no minimum (0) and no
  # maximum (Infinity).
  min = required_minimum_ruby_version || 0
  max = required_maximum_ruby_version || Float::INFINITY

  min <= version && max >= version
end