class RuboCop::Cop::Style::ParallelAssignment::RescueCorrector
An internal class for correcting parallel assignment protected by rescue
Public Instance Methods
correction()
click to toggle source
Calls superclass method
RuboCop::Cop::Style::ParallelAssignment::GenericCorrector#correction
# File lib/rubocop/cop/style/parallel_assignment.rb, line 225 def correction _node, rescue_clause = *node.parent _, _, rescue_result = *rescue_clause # If the parallel assignment uses a rescue modifier and it is the # only contents of a method, then we want to make use of the # implicit begin if node.parent.parent && node.parent.parent.def_type? super + def_correction(rescue_result) else begin_correction(rescue_result) end end
correction_range()
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 239 def correction_range node.parent.source_range end
Private Instance Methods
begin_correction(rescue_result)
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 250 def begin_correction(rescue_result) "begin\n" \ "#{indentation(node)}" \ "#{assignment.join("\n#{indentation(node)}")}" \ "\n#{offset(node)}rescue\n" \ "#{indentation(node)}#{rescue_result.source}" \ "\n#{offset(node)}end" end
def_correction(rescue_result)
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 245 def def_correction(rescue_result) "\nrescue" \ "\n#{offset(node)}#{rescue_result.source}" end