class Fantasy::Event::Event
Attributes
name[R]
Public Class Methods
new(name)
click to toggle source
# File lib/fantasy-irc/events.rb, line 36 def initialize(name) puts "New Event with name #{name}" @name = name @callbacks = Hash.new end
Public Instance Methods
call(args=nil)
click to toggle source
# File lib/fantasy-irc/events.rb, line 49 def call(args=nil) if @callbacks.empty? then return end @callbacks.each { |uuid, proc| proc.call(*args) } end
register(&callback)
click to toggle source
# File lib/fantasy-irc/events.rb, line 42 def register(&callback) uuid = SecureRandom.uuid() @callbacks[uuid] = callback puts "#{self}: registered callback #{callback} with uuid #{uuid}." end