Class: RuboCop::TargetRuby Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/target_ruby.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The kind of Ruby that code inspected by RuboCop is written in.

Defined Under Namespace

Classes: BundlerLockFile, Default, GemspecFile, RuboCopConfig, RuboCopEnvVar, RubyVersionFile, Source, ToolVersionsFile

Constant Summary collapse

DEFAULT_VERSION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

2.7

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ TargetRuby

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TargetRuby.



284
285
286
# File 'lib/rubocop/target_ruby.rb', line 284

def initialize(config)
  @config = config
end

Class Method Details

.supported_versionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



269
270
271
# File 'lib/rubocop/target_ruby.rb', line 269

def self.supported_versions
  KNOWN_RUBIES
end

Instance Method Details

#rubocop_version_with_supportObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



300
301
302
303
304
305
306
# File 'lib/rubocop/target_ruby.rb', line 300

def rubocop_version_with_support
  if supported?
    RuboCop::Version::STRING
  else
    OBSOLETE_RUBIES[version]
  end
end

#sourceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



288
289
290
# File 'lib/rubocop/target_ruby.rb', line 288

def source
  @source ||= SOURCES.each.lazy.map { |c| c.new(@config) }.detect(&:version)
end

#supported?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


296
297
298
# File 'lib/rubocop/target_ruby.rb', line 296

def supported?
  KNOWN_RUBIES.include?(version)
end

#versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



292
293
294
# File 'lib/rubocop/target_ruby.rb', line 292

def version
  source.version
end