Class: Ellen::Action

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, options = {}, &block) ⇒ Action

Returns a new instance of Action.



5
6
7
8
9
# File 'lib/ellen/action.rb', line 5

def initialize(pattern, options = {}, &block)
  @pattern = pattern
  @options = options
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/ellen/action.rb', line 3

def block
  @block
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/ellen/action.rb', line 3

def options
  @options
end

#patternObject (readonly)

Returns the value of attribute pattern.



3
4
5
# File 'lib/ellen/action.rb', line 3

def pattern
  @pattern
end

Instance Method Details

#all?Boolean

Returns:

  • (Boolean)


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

def all?
  !!options[:all]
end

#call(handler, message) ⇒ Object



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

def call(handler, message)
  handler.robot.instance_exec(message, &block) if message.match pattern_with(handler.robot.name)
end

#descriptionObject



19
20
21
# File 'lib/ellen/action.rb', line 19

def description
  options[:description] || "(no description)"
end