Ruby request compare?

I want to compare the difference between the two commit codes by Ruby. At present, the API can only see the number of lines to be added or deleted and the code to be added or deleted. I want to get the new or edited code directly without displaying the deleted code. How can I write a Ruby request?