Class: Fantasy::Event::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/fantasy-irc/events.rb

Instance Method Summary collapse

Constructor Details

#initializeFactory

Returns a new instance of Factory.



6
7
8
9
# File 'lib/fantasy-irc/events.rb', line 6

def initialize
    puts "Initializing new Event::Factory #{self}"
    @events = Hash.new
end

Instance Method Details

#by_name(name) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/fantasy-irc/events.rb', line 22

def by_name name
    name.downcase!

    if not @events[name] then
        raise "Tried to access unknown event \"#{name}\" in Event::Factory \"#{self}\""
    end

    @events[name]
end

#create(name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/fantasy-irc/events.rb', line 11

def create name
    name.downcase!

    if not @events[name].nil? then
        return @events[name]
        # TODO: log warning
    end

    @events[name] = Event.new(name)
end