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 = {}) ⇒ Action

Returns a new instance of Action.



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

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

Instance Attribute Details

#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)


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

def all?
  !!options[:all]
end

#call(handler, message) ⇒ Object



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

def call(handler, message)
  handler.send(name, message) if message.match pattern_with(handler.robot.name)
end

#descriptionObject



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

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

#nameObject



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

def name
  options[:name]
end