class SlackBot::MatcherGroup

Public Class Methods

new(action) click to toggle source
# File lib/slack/matchers/matcher_group.rb, line 5
def initialize(action)
  @action = action
  @matchers = []
end

Public Instance Methods

before_match(&block) click to toggle source
# File lib/slack/matchers/matcher_group.rb, line 23
def before_match(&block)
  @before_match = block
end
respond_for(msg) click to toggle source
# 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() click to toggle source
# File lib/slack/matchers/matcher_group.rb, line 27
def to_s
  "#{@action} #{@matchers.count}"
end
when() click to toggle source
# File lib/slack/matchers/matcher_group.rb, line 17
def when
  m = Matcher.new
  @matchers.push m
  return m
end