Class: AbcSize::RubyVersion::Picker

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/abc_size/ruby_version/picker.rb

Overview

Ruby version picker

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#return_supported_version_if_version_supported

Constructor Details

#initialize(parameters) ⇒ Picker

Returns a new instance of Picker.



11
12
13
14
# File 'lib/abc_size/ruby_version/picker.rb', line 11

def initialize(parameters)
  @parameters = parameters
  @parameter_index = @parameters.index('-r') || @parameters.index('--ruby')
end

Instance Attribute Details

#parameter_indexObject (readonly)

Returns the value of attribute parameter_index.



9
10
11
# File 'lib/abc_size/ruby_version/picker.rb', line 9

def parameter_index
  @parameter_index
end

#parametersObject (readonly)

Returns the value of attribute parameters.



9
10
11
# File 'lib/abc_size/ruby_version/picker.rb', line 9

def parameters
  @parameters
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
# File 'lib/abc_size/ruby_version/picker.rb', line 16

def call
  return if parameter_index.nil?

  value_index = parameter_index + 1

  parameters_version = parameters[value_index].to_f

  return_supported_version_if_version_supported(parameters_version)
end