Class: Isaac::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/isaac.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#blockObject

Returns the value of attribute block.



248
249
250
# File 'lib/isaac.rb', line 248

def block
  @block
end

#matchObject

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