Method: String#remove_quotes

Defined in:
lib/openc3/core_ext/string.rb,
ext/openc3/ext/string/string.c

#remove_quotesObject

Removes quotes from the given string if present.

"'quoted string'".remove_quotes #=> "quoted string"


179
180
181
182
183
184
185
186
187
188
189
# File 'lib/openc3/core_ext/string.rb', line 179

def remove_quotes
  return self if self.length < 2

  first_char = self[0]
  return self if (first_char != '"') && (first_char != "'")

  last_char = self[-1]
  return self if first_char != last_char

  return self[1..-2]
end