Module: AbcSize::RubyVersion::Common

Included in:
Detector, Picker
Defined in:
lib/abc_size/ruby_version.rb

Overview

common methods

Instance Method Summary collapse

Instance Method Details

#return_supported_version_if_version_supported(version) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/abc_size/ruby_version.rb', line 9

def return_supported_version_if_version_supported(version)
  supported_version = RubyVersion::SUPPORTED_VERSIONS.include?(version) ? version : nil
  raise UnsupportedVersionError, 'Unsupported Ruby version given.' if supported_version.nil?

  supported_version
rescue UnsupportedVersionError => e
  puts "#{e.message}\n"\
       "Supported versions: #{RubyVersion::SUPPORTED_VERSIONS}"
  exit
end