Class: RuboCop::Cop::IfThenCorrector

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/correctors/if_then_corrector.rb

Overview

This class autocorrects ‘if…then` structures to a multiline `if` statement

Constant Summary collapse

DEFAULT_INDENTATION_WIDTH =
2

Instance Method Summary collapse

Constructor Details

#initialize(if_node, indentation: nil) ⇒ IfThenCorrector

Returns a new instance of IfThenCorrector.



9
10
11
12
# File 'lib/rubocop/cop/correctors/if_then_corrector.rb', line 9

def initialize(if_node, indentation: nil)
  @if_node = if_node
  @indentation = indentation || DEFAULT_INDENTATION_WIDTH
end

Instance Method Details

#call(corrector) ⇒ Object



14
15
16
# File 'lib/rubocop/cop/correctors/if_then_corrector.rb', line 14

def call(corrector)
  corrector.replace(if_node, replacement)
end