Skip to content
class 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 .pp #` .Pathname also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0