このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 3.2 リファレンスマニュアル

instance method URI::Generic#query

query -> String | nil[permalink][rdoc][edit]

自身の query を文字列で返します。設定されていない場合は nil を返します。

require 'uri'
p URI.parse('http://example.com/?hoge').query   #=> "hoge"