Class: Nanoc::Core::RegexpPattern
- Inherits:
-
Pattern
- Object
- Pattern
- Nanoc::Core::RegexpPattern
show all
- Defined in:
- lib/nanoc/core/regexp_pattern.rb
Instance Method Summary
collapse
Methods inherited from Pattern
from
enabled?, included, setup_once, warn_about_performance
Constructor Details
Returns a new instance of RegexpPattern.
7
8
9
|
# File 'lib/nanoc/core/regexp_pattern.rb', line 7
def initialize(regexp)
@regexp = regexp
end
|
Instance Method Details
#captures(identifier) ⇒ Object
17
18
19
20
|
# File 'lib/nanoc/core/regexp_pattern.rb', line 17
def captures(identifier)
matches = @regexp.match(identifier.to_s)
matches&.captures
end
|
#match?(identifier) ⇒ Boolean
12
13
14
|
# File 'lib/nanoc/core/regexp_pattern.rb', line 12
def match?(identifier)
(identifier.to_s =~ @regexp) != nil
end
|
#to_s ⇒ Object
23
24
25
|
# File 'lib/nanoc/core/regexp_pattern.rb', line 23
def to_s
@regexp.to_s
end
|