class Fantasy::User::Factory
Public Class Methods
new(connection)
click to toggle source
# File lib/fantasy-irc/users.rb, line 4 def initialize connection puts "Initializing new User::Factory #{self} with connection #{connection}" @data, @data[:users] = Hash.new, Hash.new @connection = connection end
Public Instance Methods
by_name(name)
click to toggle source
# File lib/fantasy-irc/users.rb, line 25 def by_name name name.downcase! if not @data[:users][name] then raise "Tried to access unknown user \"#{name}\" in User::Factory \"#{self}\"" end @data[:users][name] end
new(name)
click to toggle source
# File lib/fantasy-irc/users.rb, line 10 def new name name = name.split(/!/, 2)[0] # remove mask name_lc = name.downcase if not @data[:users][name_lc].nil? then return @data[:users][name_lc] # TODO: log! not raise # raise "We already know the user #{name}" end @data[:users][name_lc] = User.new(name, @connection) end
Also aliased as: create