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 181 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 187 def correction assignment.join("\n#{offset(node)}") end
correction_range()
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 191 def correction_range node.source_range end
Protected Instance Methods
assignment()
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 197 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 217 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 213 def extract_sources(node) node.children.map(&:source) end
source(node)
click to toggle source
# File lib/rubocop/cop/style/parallel_assignment.rb, line 203 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