Class: RuboCop::Cop::Style::ParallelAssignment::ModifierCorrector

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

Overview

An internal class for correcting parallel assignment guarded by if, unless, while, or until

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, #display_column, #indentation, #offset

Constructor Details

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

Instance Method Details

#correctionObject



239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 239

def correction
  parent = node.parent

  modifier_range =
    Parser::Source::Range.new(parent.source_range.source_buffer,
                              parent.loc.keyword.begin_pos,
                              parent.source_range.end_pos)

  "#{modifier_range.source}\n" \
    "#{indentation(node)}" \
    "#{assignment.join("\n#{indentation(node)}")}" \
    "\n#{offset(node)}end"
end

#correction_rangeObject



253
254
255
# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 253

def correction_range
  node.parent.source_range
end