class Fantasy::Room::Room
Attributes
name[R]
users[R]
Public Class Methods
new(name, connection)
click to toggle source
# File lib/fantasy-irc/rooms.rb, line 41 def initialize name, connection if not connection.respond_to?(:send) then raise "Connection class needs to be able to respond to :send" end puts "New Room #{self.object_id} with name #{name}" @name = name @joined = false @connection = connection @users = Array::Unique.new end
Public Instance Methods
join()
click to toggle source
# File lib/fantasy-irc/rooms.rb, line 53 def join if @joined == true then raise "Already joined room #{@name}." end @connection.send("JOIN "+@name) @joined = true # TODO: maybe we should set that if we get the # correct reply. this is for testing only! XXX return self end
joined?()
click to toggle source
# File lib/fantasy-irc/rooms.rb, line 64 def joined? !!@joined end
me(message)
click to toggle source
sends a privmsg with ACTION to the room
# File lib/fantasy-irc/rooms.rb, line 89 def me message self.say "\001ACTION #{message}\001" end
note(message)
click to toggle source
sends a notice to the room
# File lib/fantasy-irc/rooms.rb, line 79 def note message if @joined == false then raise "Tried to talk to a room (#{name}) we're not in." end @connection.send('NOTICE '+@name+' :'+message) return self end
say(message)
click to toggle source
sends a privmsg to the room
# File lib/fantasy-irc/rooms.rb, line 69 def say message if @joined == false then raise "Tried to talk to a room (#{name}) we're not in." end @connection.send('PRIVMSG '+@name+' :'+message) return self end
to_s()
click to toggle source
# File lib/fantasy-irc/rooms.rb, line 103 def to_s "#{@name}" end
topic(message)
click to toggle source
sets a topic in the room
# File lib/fantasy-irc/rooms.rb, line 94 def topic message if @joined == false then raise "Tried to set topic in a room (#{name}) we're not in." end @connection.send('TOPIC '+@name+' :'+message) return self end