Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Kernel#URI

(::URI::Generic | ::string uri) -> ::URI::Generic
URI(uri)

Returns a URI object derived from the given uri, which may be a URI string or an existing URI object:

Example
require 'uri'
# Returns a new URI.
uri = URI('http://github.com/ruby/ruby')
# => #<URI::HTTP http://github.com/ruby/ruby>
# Returns the given URI.
URI(uri)
# => #<URI::HTTP http://github.com/ruby/ruby>

You must require ‘uri’ to use this method.

See also .URI #untrace_var #warn #trap also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0