class Addressable::URI

def hostname=(new_hostname)

Parameters:
  • new_hostname (String, #to_str) -- The new hostname for this URI.

Other tags:
    See: Addressable::URI#host= -
def hostname=(new_hostname)
  if new_hostname &&
      (new_hostname.respond_to?(:ipv4?) || new_hostname.respond_to?(:ipv6?))
    new_hostname = new_hostname.to_s
  elsif new_hostname && !new_hostname.respond_to?(:to_str)
    raise TypeError, "Can't convert #{new_hostname.class} into String."
  end
  v = new_hostname ? new_hostname.to_str : nil
  v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
  self.host = v
end