Class: RubocopTodoCorrector::Commands::Pick

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop_todo_corrector/commands/pick.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ignore_file_path:, mode:, only_safe:, rubocop_todo_path:) ⇒ Pick

Returns a new instance of Pick.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rubocop_todo_corrector/commands/pick.rb', line 29

def initialize(
  ignore_file_path:,
  mode:,
  only_safe:,
  rubocop_todo_path:
)
  @ignore_file_path = ignore_file_path
  @mode = mode
  @only_safe = only_safe
  @rubocop_todo_path = rubocop_todo_path
end

Class Method Details

.call(ignore_file_path:, mode:, only_safe:, rubocop_todo_path:) ⇒ Object

Parameters:

  • ignore_file_path (String)
  • mode (String)
  • only_safe (Boolean)
  • rubocop_todo_path (String)


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rubocop_todo_corrector/commands/pick.rb', line 14

def call(
  ignore_file_path:,
  mode:,
  only_safe:,
  rubocop_todo_path:
)
  new(
    ignore_file_path:,
    mode:,
    only_safe:,
    rubocop_todo_path:
  ).call
end

Instance Method Details

#callObject



41
42
43
44
45
46
47
48
49
# File 'lib/rubocop_todo_corrector/commands/pick.rb', line 41

def call
  check_rubocop_todo_existence
  cop_name = picked_cop&.[](:name)
  if cop_name
    ::Kernel.puts(cop_name)
  else
    ::Kernel.abort('No cop was picked.')
  end
end