Class: Isaac::Event
- Inherits:
-
Object
- Object
- Isaac::Event
- Defined in:
- lib/isaac.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#match ⇒ Object
Returns the value of attribute match.
Instance Method Summary collapse
-
#initialize(match, block) ⇒ Event
constructor
A new instance of Event.
-
#invoke(params = {}) ⇒ Object
Execute event in the context of EventContext.
Constructor Details
#initialize(match, block) ⇒ Event
Returns a new instance of Event.
249 250 251 252 |
# File 'lib/isaac.rb', line 249 def initialize(match, block) @match = match @block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
248 249 250 |
# File 'lib/isaac.rb', line 248 def block @block end |
#match ⇒ Object
Returns the value of attribute match.
248 249 250 |
# File 'lib/isaac.rb', line 248 def match @match end |
Instance Method Details
#invoke(params = {}) ⇒ Object
Execute event in the context of EventContext.
255 256 257 258 259 260 261 262 |
# File 'lib/isaac.rb', line 255 def invoke(params={}) match = params[:message].match(@match) if @match && params[:message] params.merge!(:match => match) context = EventContext.new(params) context.instance_eval(&@block) context.commands end |