Class: Mailman::Route::RegexpMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/mailman/route/regexp_matcher.rb

Overview

Matches using a Regexp.

Instance Attribute Summary

Attributes inherited from Matcher

#pattern

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#compile!, create, inherited, #initialize

Constructor Details

This class inherits a constructor from Mailman::Route::Matcher

Class Method Details

.valid_pattern?(pattern) ⇒ Boolean

Returns:

  • (Boolean)

17
18
19
# File 'lib/mailman/route/regexp_matcher.rb', line 17

def self.valid_pattern?(pattern)
  pattern.class == Regexp
end

Instance Method Details

#match(string) ⇒ ({:captures => <String>}, <String>)

Matches against a string using the stored Regexp.

Parameters:

  • string (String)

    the string to match against

Returns:

  • (({:captures => <String>}, <String>))

    the params hash with :captures set to an array of captures, and an array of captures.


10
11
12
13
14
15
# File 'lib/mailman/route/regexp_matcher.rb', line 10

def match(string)
  if match = @pattern.match(string)
    captures = match.captures
    [{:captures => captures}, captures]
  end
end