Class: Ellen::Handlers::Base

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

Direct Known Subclasses

Help, Ping, Whoami

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Env::Validatable

#validate, #validate!

Constructor Details

#initialize(robot) ⇒ Base

Returns a new instance of Base.



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

def initialize(robot)
  @robot = robot
  validate!
end

Instance Attribute Details

#robotObject (readonly)

Returns the value of attribute robot.



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

def robot
  @robot
end

Class Method Details

.actionsObject



15
16
17
# File 'lib/ellen/handlers/base.rb', line 15

def actions
  []
end

.inherited(child) ⇒ Object



7
8
9
# File 'lib/ellen/handlers/base.rb', line 7

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

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



11
12
13
# File 'lib/ellen/handlers/base.rb', line 11

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

Instance Method Details

#call(message) ⇒ Object



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

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