class Addressable::URI

def port=(new_port)

Parameters:
  • new_port (String, Integer, #to_s) -- The new port component.
def port=(new_port)
  if new_port != nil && new_port.respond_to?(:to_str)
    new_port = Addressable::URI.unencode_component(new_port.to_str)
  end
  if new_port != nil && !(new_port.to_s =~ /^\d+$/)
    raise InvalidURIError,
      "Invalid port number: #{new_port.inspect}"
  end
  @port = new_port.to_s.to_i
  @port = nil if @port == 0
  # Reset dependant values
  @authority = nil
  @normalized_port = nil
  @uri_string = nil
  @hash = nil
  # Ensure we haven't created an invalid URI
  validate()
end