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

instance method URI::Generic#route_to

route_to(dst) -> URI::Generic[permalink][rdoc]

自身から dst への相対パスを返します。

[PARAM] dst:
URI を文字列かURIオブジェクトで与えます。

例:

require 'uri'
p URI.parse('http://example.com/').route_to('http://example.com/foo/bar.html')

#=> #<URI::Generic:0x20100198 URL:foo/bar.html>