Class: PathSpec::RegexSpec

Inherits:
Spec
  • Object
show all
Defined in:
lib/pathspec/regexspec.rb

Overview

Simple regex-based spec

Direct Known Subclasses

GitIgnoreSpec

Instance Attribute Summary

Attributes inherited from Spec

#pattern, #regex

Instance Method Summary collapse

Methods inherited from Spec

#to_s

Constructor Details

#initialize(pattern) ⇒ RegexSpec

Returns a new instance of RegexSpec.



6
7
8
9
10
11
# File 'lib/pathspec/regexspec.rb', line 6

def initialize(pattern)
  @pattern = pattern.dup
  @regex = Regexp.compile pattern

  super
end

Instance Method Details

#inclusive?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/pathspec/regexspec.rb', line 13

def inclusive?
  true
end

#match(path) ⇒ Object



17
18
19
# File 'lib/pathspec/regexspec.rb', line 17

def match(path)
  @regex&.match(path)
end