# File lib/addressable/uri.rb, line 988 def port=(new_port) # Check for frozenness raise TypeError, "Can't modify frozen URI." if self.frozen? 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 @inferred_port = nil @normalized_port = nil @uri_string = nil # Ensure we haven't created an invalid URI validate() end