Class: RuboCop::Cop::Style::ParallelAssignment::RescueCorrector
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
GenericCorrector
|
|
Instance Chain:
|
|
Inherits: |
RuboCop::Cop::Style::ParallelAssignment::GenericCorrector
|
Defined in: | lib/rubocop/cop/style/parallel_assignment.rb |
Overview
An internal class for correcting parallel assignment protected by rescue
Constant Summary
::RuboCop::Cop::Alignment
- Included
Class Method Summary
GenericCorrector
- Inherited
Instance Attribute Summary
GenericCorrector
- Inherited
::RuboCop::Cop::Alignment
- Included
Instance Method Summary
- #correction
- #correction_range
- #begin_correction(rescue_result) private
- #def_correction(rescue_result) private
GenericCorrector
- Inherited
::RuboCop::Cop::Alignment
- Included
Constructor Details
This class inherits a constructor from RuboCop::Cop::Style::ParallelAssignment::GenericCorrector
Instance Method Details
#begin_correction(rescue_result) (private)
[ GitHub ]# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 259
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
#correction
[ GitHub ]# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 237
def correction # 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 rhs.parent.parent.parent&.def_type? super + def_correction(rescue_result) else begin_correction(rescue_result) end end
#correction_range
[ GitHub ]# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 248
def correction_range rhs.parent.parent.source_range end
#def_correction(rescue_result) (private)
[ GitHub ]# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 254
def def_correction(rescue_result) "\nrescue" \ "\n#{offset(node)}#{rescue_result.source}" end