Class: RuboCop::StringInterpreter
- Inherits:
-
Object
- Object
- RuboCop::StringInterpreter
- Defined in:
- lib/rubocop/string_interpreter.rb
Overview
Take a string with embedded escapes, and convert the escapes as the Ruby interpreter would when reading a double-quoted string literal. For example, ā\nā will be converted to ānā.
Class Method Summary collapse
Class Method Details
.interpret(string) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/rubocop/string_interpreter.rb', line 24 def interpret(string) # We currently don't handle \cx, \C-x, and \M-x string.gsub(STRING_ESCAPE_REGEX) do |escape| STRING_ESCAPES[escape] || interpret_string_escape(escape) end end |