class RuboCop::Cop::StringLiteralCorrector

This auto-corrects string literals

Public Class Methods

correct(node, style) click to toggle source
# File lib/rubocop/cop/correctors/string_literal_corrector.rb, line 10
def correct(node, style)
  return if node.dstr_type?

  lambda do |corrector|
    str = node.str_content
    if style == :single_quotes
      corrector.replace(node.source_range, to_string_literal(str))
    else
      corrector.replace(node.source_range, str.inspect)
    end
  end
end