Module: Cognition
- Extended by:
- Cognition
- Included in:
- Cognition
- Defined in:
- lib/cognition.rb,
lib/cognition/matcher.rb,
lib/cognition/message.rb,
lib/cognition/version.rb,
lib/cognition/responder.rb,
lib/cognition/plugins/base.rb,
lib/cognition/plugins/default.rb
Defined Under Namespace
Modules: Plugins
Classes: Matcher, Message, Responder
Constant Summary
collapse
- VERSION =
"1.1.2"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#matchers=(value) ⇒ Object
Sets the attribute matchers
11
12
13
|
# File 'lib/cognition.rb', line 11
def matchers=(value)
@matchers = value
end
|
#plugins=(value) ⇒ Object
Sets the attribute plugins
11
12
13
|
# File 'lib/cognition.rb', line 11
def plugins=(value)
@plugins = value
end
|
Instance Method Details
#help ⇒ Object
36
37
38
|
# File 'lib/cognition.rb', line 36
def help
matchers.map(&:help)
end
|
#plugin_names ⇒ Object
32
33
34
|
# File 'lib/cognition.rb', line 32
def plugin_names
plugins.map { |p| p.class.name }
end
|
#process(msg, metadata = {}) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/cognition.rb', line 13
def process(msg, metadata = {})
if msg.respond_to? :command
process_msg(msg)
else
process_string(msg.to_s, metadata)
end
end
|
#register(klass) ⇒ Object
21
22
23
24
|
# File 'lib/cognition.rb', line 21
def register(klass)
return false if plugin_names.include? klass.to_s
plugins << klass.new
end
|
#reset ⇒ Object
26
27
28
29
30
|
# File 'lib/cognition.rb', line 26
def reset
@matchers = []
@plugins = []
register(Cognition::Plugins::Default)
end
|