Class: StreamBot::Event

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

Overview

event class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Event

Returns a new instance of Event.



6
7
8
9
# File 'lib/streambot/event.rb', line 6

def initialize(name)
  LOG.debug "initialize: #{name}"
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/streambot/event.rb', line 4

def name
  @name
end

Instance Method Details

#receive(method = nil, &block) ⇒ Object



11
12
13
14
15
# File 'lib/streambot/event.rb', line 11

def receive(method=nil, & block)
  LOG.debug "receive: #{self.name}" 
  @handler = method if !method.nil?
  @handler = block if !block.nil?
end

#trigger(*args) ⇒ Object



17
18
19
20
# File 'lib/streambot/event.rb', line 17

def trigger(* args)
  LOG.debug "trigger: #{self.name}"
  @handler.call(*args) if !@handler.nil?
end