Class: RuboCop::Cop::Style::ParallelAssignment::RescueCorrector

Inherits:
GenericCorrector
  • Object
show all
Defined in:
lib/rubocop/cop/style/parallel_assignment.rb

Overview

An internal class for correcting parallel assignment protected by rescue

Constant Summary

Constants included from AutocorrectAlignment

AutocorrectAlignment::SPACE

Instance Attribute Summary

Attributes inherited from GenericCorrector

#config, #node

Instance Method Summary collapse

Methods inherited from GenericCorrector

#initialize

Methods included from AutocorrectAlignment

#autocorrect, #check_alignment, #configured_indentation_width, #indentation, #offset, #start_of_line?

Constructor Details

This class inherits a constructor from RuboCop::Cop::Style::ParallelAssignment::GenericCorrector

Instance Method Details

#correctionObject



179
180
181
182
183
184
185
186
187
188
# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 179

def correction
  _node, rescue_clause = *node.parent
  _, _, rescue_result = *rescue_clause

  "begin\n" <<
    indentation(node) << assignment.join("\n#{indentation(node)}") <<
    "\n#{offset(node)}rescue\n" <<
    indentation(node) << rescue_result.loc.expression.source <<
    "\n#{offset(node)}end"
end

#correction_rangeObject



190
191
192
# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 190

def correction_range
  node.parent.loc.expression
end