class Fantasy::Room::Factory

Public Class Methods

new(connection) click to toggle source
# File lib/fantasy-irc/rooms.rb, line 4
def initialize connection
    puts "Initializing new Room::Factory #{self} with connection #{connection}"
    @data, @data[:rooms] = Hash.new, Hash.new
    @connection = connection
end

Public Instance Methods

all() click to toggle source
# File lib/fantasy-irc/rooms.rb, line 33
def all
    @data[:rooms]
end
by_name(name) click to toggle source
# File lib/fantasy-irc/rooms.rb, line 22
def by_name name
    name.downcase!

    if not @data[:rooms][name] then
        raise "Tried to access unknown room \"#{name}\" in Room::Factory \"#{self}\""
        #TODO: log
    end

    @data[:rooms][name]
end
create(name)
Alias for: new
new(name) click to toggle source
# File lib/fantasy-irc/rooms.rb, line 10
def new name
    name.downcase!

    if not @data[:rooms][name].nil? then
        raise "We already know the room #{name}"
    end

    @data[:rooms][name] = Room.new(name, @connection)
end
Also aliased as: create