Class: Ellen::Handlers::Base

Inherits:
Object
  • Object
show all
Extended by:
Mem
Defined in:
lib/ellen/handlers/base.rb

Direct Known Subclasses

Help, Ping

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(robot) ⇒ Base

Returns a new instance of Base.



34
35
36
# File 'lib/ellen/handlers/base.rb', line 34

def initialize(robot)
  @robot = robot
end

Instance Attribute Details

#robotObject (readonly)

Returns the value of attribute robot.



32
33
34
# File 'lib/ellen/handlers/base.rb', line 32

def robot
  @robot
end

Class Method Details

.actionsObject



26
27
28
# File 'lib/ellen/handlers/base.rb', line 26

def actions
  []
end

.inherited(child) ⇒ Object



18
19
20
# File 'lib/ellen/handlers/base.rb', line 18

def inherited(child)
  Ellen.handlers << child
end

.on(pattern, options = {}, &block) ⇒ Object



22
23
24
# File 'lib/ellen/handlers/base.rb', line 22

def on(pattern, options = {}, &block)
  actions << Action.new(pattern, options, &block)
end

Instance Method Details

#call(message) ⇒ Object



38
39
40
41
42
# File 'lib/ellen/handlers/base.rb', line 38

def call(message)
  self.class.actions.each do |action|
    action.call(self, message)
  end
end