We could have done this with

  line_buffer.gsub(/#{input}$/, '').end_with?('"', "'")

which I think reads better.