Class: SlackBot::MatcherGroup
- Inherits:
-
Object
- Object
- SlackBot::MatcherGroup
- Defined in:
- lib/slack/matchers/matcher_group.rb
Instance Method Summary collapse
- #before_match(&block) ⇒ Object
-
#initialize(action) ⇒ MatcherGroup
constructor
A new instance of MatcherGroup.
- #respond_for(msg) ⇒ Object
- #to_s ⇒ Object
- #when ⇒ Object
Constructor Details
#initialize(action) ⇒ MatcherGroup
Returns a new instance of MatcherGroup.
5 6 7 8 |
# File 'lib/slack/matchers/matcher_group.rb', line 5 def initialize(action) @action = action @matchers = [] end |
Instance Method Details
#before_match(&block) ⇒ Object
23 24 25 |
# File 'lib/slack/matchers/matcher_group.rb', line 23 def before_match(&block) @before_match = block end |
#respond_for(msg) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/slack/matchers/matcher_group.rb', line 10 def respond_for(msg) @before_match.call(msg) if @before_match @matchers.each do |m| break if m.run_on(msg) end end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/slack/matchers/matcher_group.rb', line 27 def to_s "#{@action} #{@matchers.count}" end |