Class: Nanoc::Int::RegexpPattern Private

Inherits:
Pattern
  • Object
show all
Defined in:
lib/nanoc/base/entities/pattern.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Methods inherited from Pattern

from

Methods included from ContractsSupport

included

Constructor Details

#initialize(regexp) ⇒ RegexpPattern

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RegexpPattern.



61
62
63
# File 'lib/nanoc/base/entities/pattern.rb', line 61

def initialize(regexp)
  @regexp = regexp
end

Instance Method Details

#captures(identifier) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



71
72
73
74
# File 'lib/nanoc/base/entities/pattern.rb', line 71

def captures(identifier)
  matches = @regexp.match(identifier.to_s)
  matches && matches.captures
end

#match?(identifier) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


66
67
68
# File 'lib/nanoc/base/entities/pattern.rb', line 66

def match?(identifier)
  (identifier.to_s =~ @regexp) != nil
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



77
78
79
# File 'lib/nanoc/base/entities/pattern.rb', line 77

def to_s
  @regexp.to_s
end