Class: MatchFilter
- Defined in:
- lib/extensions/mspec/mspec/runner/filters/match.rb
Direct Known Subclasses
Instance Method Summary collapse
- #===(string) ⇒ Object
-
#initialize(what, *strings) ⇒ MatchFilter
constructor
A new instance of MatchFilter.
- #register ⇒ Object
- #to_regexp(*strings) ⇒ Object
- #unregister ⇒ Object
Constructor Details
#initialize(what, *strings) ⇒ MatchFilter
Returns a new instance of MatchFilter.
2 3 4 5 |
# File 'lib/extensions/mspec/mspec/runner/filters/match.rb', line 2 def initialize(what, *strings) @what = what @descriptions = to_regexp(*strings) end |
Instance Method Details
#===(string) ⇒ Object
11 12 13 |
# File 'lib/extensions/mspec/mspec/runner/filters/match.rb', line 11 def ===(string) @descriptions.any? { |d| d === string } end |
#register ⇒ Object
15 16 17 |
# File 'lib/extensions/mspec/mspec/runner/filters/match.rb', line 15 def register MSpec.register @what, self end |
#to_regexp(*strings) ⇒ Object
7 8 9 |
# File 'lib/extensions/mspec/mspec/runner/filters/match.rb', line 7 def to_regexp(*strings) strings.map { |str| Regexp.new Regexp.escape(str) } end |
#unregister ⇒ Object
19 20 21 |
# File 'lib/extensions/mspec/mspec/runner/filters/match.rb', line 19 def unregister MSpec.unregister @what, self end |