Ruby 2.1.0 リファレンスマニュアル > ライブラリ一覧 > uriライブラリ > URI::Genericクラス > coerce

instance method URI::Generic#coerce

coerce(oth) -> [URI, URI][permalink][rdoc]

引数 oth をパースして [パース後の oth, self] の配列を返します。

[PARAM] oth:
URI オブジェクトか文字列を指定します。

例:

require 'uri'

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