Class: RuboCop::Cop::IfThenCorrector
- Inherits:
-
Object
- Object
- RuboCop::Cop::IfThenCorrector
- 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
- #call(corrector) ⇒ Object
-
#initialize(if_node, indentation: nil) ⇒ IfThenCorrector
constructor
A new instance of IfThenCorrector.
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 |