Method: Addressable::URI#hostname=
- Defined in:
- lib/addressable/uri.rb
#hostname=(new_hostname) ⇒ Object
This method is same as URI::Generic#host= except the argument can be a bare IPv6 address (or ‘IPvFuture’).
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 |
# File 'lib/addressable/uri.rb', line 1190 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 |