class Plugin
Attributes
name[R]
Public Class Methods
new(name)
click to toggle source
# File lib/fantasy-irc/plugins.rb, line 50 def initialize name @name = name @handlers = {} end
Public Instance Methods
handle(pattern, &block)
click to toggle source
# File lib/fantasy-irc/plugins.rb, line 55 def handle pattern, &block @handlers[pattern] = block end
handle!(command, data, args=[])
click to toggle source
# File lib/fantasy-irc/plugins.rb, line 69 def handle! command, data, args=[] #puts "trying to handle #{command} with #{data} and #{args}" @handlers.each do |pattern, block| if command.match(pattern) then puts "#{block} handles #{command}" begin block.call data, args rescue Exception => e puts "#{block} failed with Exception #{e}" puts e.backtrace end break end end end
handles?(command)
click to toggle source
# File lib/fantasy-irc/plugins.rb, line 59 def handles? command @handlers.keys.each do |pattern| if command.match pattern then return true end end return false end