Something like this?

    line_buffer.gsub(/#{Regexp.quote(input)}$/, '').end_with?('"', "'")

Probably it is not a big gain, you're right. And it is a private method, so the implications are not big and it can always be changed in the future.