def to_uri
      # map the URL scheme to a URI class
      url_class = SCHEMES.fetch(self.scheme.name,::URI::Generic)

      host = if self.host_name
               self.host_name.address
             end
      port = if self.port
               self.port.number
             end

      query = unless self.query_params.empty?
                self.query_string
              end

      # build the URI
      return url_class.build(
        :scheme   => self.scheme.name,
        :host     => host,
        :port     => port,
        :path     => self.path,
        :query    => query,
        :fragment => self.fragment
      )
    end
def to_uri
      # map the URL scheme to a URI class
      url_class = SCHEMES.fetch(self.scheme.name,::URI::Generic)

      host = if self.host_name
               self.host_name.address
             end
      port = if self.port
               self.port.number
             end

      query = unless self.query_params.empty?
                self.query_string
              end

      # build the URI
      return url_class.build(
        :scheme   => self.scheme.name,
        :host     => host,
        :port     => port,
        :path     => self.path,
        :query    => query,
        :fragment => self.fragment
      )
    end
Builds a URI object from the URL.

 @return [URI::HTTP, URI::HTTPS]
   The URI object created from the URL attributes.

 @since 1.0.0

 @api public