Having Server#to_s alias the hostname would cause problems when the
hostname was nil (e.g. after a disconnect). Fix by making sure that to_s
always returns a string instead.
class Server
attr_reader :hostname, :version, :usermodes, :chanmodes
- alias :to_s :hostname
attr_reader :supports, :capabilities
attr_reader :channels, :users
str << ">"
end
+ def to_s
+ hostname.nil? ? "<no hostname>" : hostname
+ end
+
# Create a new Server, with all instance variables reset to nil (for
# scalar variables), empty channel and user lists and @supports
# initialized to the default values for all known supported features.