utils/service: simplify

This commit is contained in:
Ruoyu Zhong 2024-12-04 03:09:11 +08:00
parent bba67ec02e
commit a8a6a5bdb7
No known key found for this signature in database

View File

@ -58,26 +58,16 @@ module Utils
# quoting the entire string. # quoting the entire string.
str.each_char do |char| str.each_char do |char|
result << case char result << case char
when "\a" when "\a" then "\\a"
"\\a" when "\b" then "\\b"
when "\b" when "\f" then "\\f"
"\\b" when "\n" then "\\n"
when "\f" when "\r" then "\\r"
"\\f" when "\t" then "\\t"
when "\n" when "\v" then "\\v"
"\\n" when "\\" then "\\\\"
when "\r" when "\"" then "\\\""
"\\r" else char
when "\t"
"\\t"
when "\v"
"\\v"
when "\\"
"\\\\"
when "\""
"\\\""
else
char
end end
end end
result << "\"" result << "\""