Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

URI::Generic#coerce

coerce(oth)

Args

v

URI or String

Description

Attempts to parse other URI oth, returns [parsed_oth, self].

Usage

Example
require 'uri'

uri = URI.parse("http://my.example.com")
uri.coerce("http://foo.com")
#=> [#<URI::HTTP http://foo.com>, #<URI::HTTP http://my.example.com>]