Net HTTP Request, Force IPv6 or IPv4

I’m writing a monitoring script and checking services over IPv4 and
IPv6.

Is there a way to force ruby to use IPv4 or IPv6 depending on the check?

This is mostly for the default “net/http” and other various “net”
protocols.

For example:
response = Net::HTTP.get_response(URI.parse(checkurl))

I am trying to have the GET request to use IPv4 or IPv6 depending on a
parameter.

Thanks,