Class: MatchFilter

Inherits:
Object show all
Defined in:
lib/mspec/runner/filters/match.rb

Direct Known Subclasses

RegexpFilter

Instance Method Summary collapse

Constructor Details

#initialize(what, *strings) ⇒ MatchFilter

Returns a new instance of MatchFilter


2
3
4
5
# File 'lib/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/mspec/runner/filters/match.rb', line 11

def ===(string)
  @descriptions.any? { |d| d === string }
end

#registerObject


15
16
17
# File 'lib/mspec/runner/filters/match.rb', line 15

def register
  MSpec.register @what, self
end

#to_regexp(*strings) ⇒ Object


7
8
9
# File 'lib/mspec/runner/filters/match.rb', line 7

def to_regexp(*strings)
  strings.map { |str| Regexp.new Regexp.escape(str) }
end

#unregisterObject


19
20
21
# File 'lib/mspec/runner/filters/match.rb', line 19

def unregister
  MSpec.unregister @what, self
end