Method: Addressable::URI#host=

Defined in:
lib/addressable/uri.rb

#host=(new_host) ⇒ Object

Sets the host component for this URI.

Parameters:

  • new_host (String, #to_str)

    The new host component.



1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
# File 'lib/addressable/uri.rb', line 1156

def host=(new_host)
  if new_host && !new_host.respond_to?(:to_str)
    raise TypeError, "Can't convert #{new_host.class} into String."
  end
  @host = new_host ? new_host.to_str : nil

  # Reset dependent values
  @authority = nil
  @normalized_host = nil
  remove_composite_values

  # Ensure we haven't created an invalid URI
  validate()
end