Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
URI::Generic#port=
port=(v)
lib/uri/generic.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/uri/generic.rb, line 729
def port=(v)
check_port(v)
set_port(v)
port
end
Args
v
Description
Public setter for the port component v (with validation).
See also URI::Generic.check_port.
Usage
Example
require 'uri' uri = URI.parse("http://my.example.com") uri.port = 8080 uri.to_s #=> "http://my.example.com:8080"