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/plugins/base.rb,
lib/cognition/plugins/default.rb
Defined Under Namespace
Modules: Plugins
Classes: Matcher, Message
Constant Summary
collapse
- VERSION =
"1.0.3"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#matchers=(value) ⇒ Object
Sets the attribute matchers
10
11
12
|
# File 'lib/cognition.rb', line 10
def matchers=(value)
@matchers = value
end
|
#plugins=(value) ⇒ Object
Sets the attribute plugins
10
11
12
|
# File 'lib/cognition.rb', line 10
def plugins=(value)
@plugins = value
end
|
Instance Method Details
#help ⇒ Object
35
36
37
|
# File 'lib/cognition.rb', line 35
def help
matchers.map(&:help)
end
|
#plugin_names ⇒ Object
31
32
33
|
# File 'lib/cognition.rb', line 31
def plugin_names
plugins.map { |p| p.class.name }
end
|
#process(msg, metadata = {}) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/cognition.rb', line 12
def process(msg, metadata = {})
if msg.respond_to? :command
process_msg(msg)
else
process_string(msg.to_s, metadata)
end
end
|
#register(klass) ⇒ Object
20
21
22
23
|
# File 'lib/cognition.rb', line 20
def register(klass)
return false if plugin_names.include? klass.to_s
plugins << klass.new
end
|
#reset ⇒ Object
25
26
27
28
29
|
# File 'lib/cognition.rb', line 25
def reset
@matchers = []
@plugins = []
register(Cognition::Plugins::Default)
end
|