diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-09-30 01:37:05 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2010-09-30 01:37:05 +0200 |
commit | 0442fc1546a2f5ca3bb68e4cdae2e4cd8ae1df45 (patch) | |
tree | 61cdebfbc8be01ca31ef4eb7db93b360327f15ca /lib | |
parent | 0457e6c4a61250d6cee1927b5b66095560b389b6 (diff) |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/irc.rb | 5 |
1 files changed, 4 insertions, 1 deletions
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? ? "<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. |