Module: Robut::Plugin::ClassMethods
- Defined in:
- lib/robut/plugin.rb
Overview
Contains methods that will be added directly to a class including Robut::Plugin.
Instance Method Summary collapse
-
#desc(string) ⇒ Object
Provides a description for the next matcher.
-
#match(regexp, options = {}, &action) ⇒ Object
Sets up a 'matcher' that will try to match input being sent to this plugin with a regular expression.
-
#matchers ⇒ Object
A list of regular expressions to apply to input being sent to the plugin, along with blocks of actions to perform.
Instance Method Details
#desc(string) ⇒ Object
Provides a description for the next matcher
33 34 35 |
# File 'lib/robut/plugin.rb', line 33 def desc(string) @last_description = string end |
#match(regexp, options = {}, &action) ⇒ Object
Sets up a 'matcher' that will try to match input being sent to
this plugin with a regular expression. If the expression
matches, action will be performed. action will be passed any
captured groups in the regular expression as parameters. For
example:
match /^say hello to (\w+)/ do |name| ...
The action is run in the context of an instance of a class that
includes Robut::Plugin. Like handle, an action explicitly
returning true will stop the plugin chain from matching any
further.
Supported options:
:sent_to_me - only try to match this regexp if it contains an @reply to robut.
This will also strip the @reply from the we're trying
to match on, so ^ and $ will still do the right thing.
27 28 29 30 |
# File 'lib/robut/plugin.rb', line 27 def match(regexp, = {}, &action) matchers << [regexp, , action, @last_description] @last_description = nil end |
#matchers ⇒ Object
A list of regular expressions to apply to input being sent to the plugin, along with blocks of actions to perform. Each element is a [regexp, options, action, description] array.
40 41 42 |
# File 'lib/robut/plugin.rb', line 40 def matchers @matchers ||= [] end |