From 0442fc1546a2f5ca3bb68e4cdae2e4cd8ae1df45 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 30 Sep 2010 01:37:05 +0200 Subject: IRC framework: Server#to_s must always return a String 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. --- lib/rbot/irc.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/rbot/irc.rb') diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 326e25ef..c57b252f 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -1525,7 +1525,6 @@ module Irc class Server attr_reader :hostname, :version, :usermodes, :chanmodes - alias :to_s :hostname attr_reader :supports, :capabilities attr_reader :channels, :users @@ -1556,6 +1555,10 @@ module Irc str << ">" end + def to_s + hostname.nil? ? "" : 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. -- cgit v1.2.3