Class: CrazyDoll::EventManager
- Inherits:
-
Object
- Object
- CrazyDoll::EventManager
- Defined in:
- lib/crazy_doll/events.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#irc ⇒ Object
readonly
Returns the value of attribute irc.
Instance Method Summary collapse
- #fire(type, name, opts = {}, line = '') ⇒ Object
-
#initialize(irc) ⇒ EventManager
constructor
A new instance of EventManager.
- #register(type, klass, opts) ⇒ Object
Constructor Details
#initialize(irc) ⇒ EventManager
Returns a new instance of EventManager.
29 30 31 32 33 |
# File 'lib/crazy_doll/events.rb', line 29 def initialize(irc) @irc = irc @irc.event_manager = self @events = { :sys => {}, :get => {}, :put => {} } end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
28 29 30 |
# File 'lib/crazy_doll/events.rb', line 28 def config @config end |
#events ⇒ Object (readonly)
Returns the value of attribute events.
28 29 30 |
# File 'lib/crazy_doll/events.rb', line 28 def events @events end |
#irc ⇒ Object (readonly)
Returns the value of attribute irc.
28 29 30 |
# File 'lib/crazy_doll/events.rb', line 28 def irc @irc end |
Instance Method Details
#fire(type, name, opts = {}, line = '') ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/crazy_doll/events.rb', line 35 def fire(type, name, opts = {}, line = '') type, name = type.to_sym, name.to_sym return false unless [:sys, :get, :put].include?(type) @events[type][name] ||= [] @events[type][name].each { |x| x.call(opts, line) } fire(type, :command_message, opts, line) if opts.is_a?(CrazyDoll::Message) and opts.command == 'PRIVMSG' and name != :command_message end |