class RuboCop::Cop::Style::ParallelAssignment::GenericCorrector
An internal class for correcting parallel assignment
Attributes
config[R]
node[R]
Public Class Methods
new(node, config, new_elements)
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 180 def initialize(node, config, new_elements) @node = node @config = config @new_elements = new_elements end
Public Instance Methods
correction()
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 186 def correction assignment.join("\n#{offset(node)}") end
correction_range()
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 190 def correction_range node.source_range end
Protected Instance Methods
assignment()
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 196 def assignment @new_elements.map { |lhs, rhs| "#{lhs.source} = #{source(rhs)}" } end
Private Instance Methods
cop_config()
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 216 def cop_config @config.for_cop('Style/ParallelAssignment') end
extract_sources(node)
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 212 def extract_sources(node) node.children.map(&:source) end
source(node)
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 202 def source(node) if node.str_type? && node.loc.begin.nil? "'#{node.source}'" elsif node.sym_type? && node.loc.begin.nil? ":#{node.source}" else node.source end end