Class: Nanoc::Core::Pattern

Inherits:
Object
  • Object
show all
Includes:
ContractsSupport
Defined in:
lib/nanoc/core/pattern.rb

Direct Known Subclasses

RegexpPattern, StringPattern

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

#initialize(_obj) ⇒ Pattern

Returns a new instance of Pattern.

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/nanoc/core/pattern.rb', line 24

def initialize(_obj)
  raise NotImplementedError
end

Class Method Details

.from(obj) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nanoc/core/pattern.rb', line 9

def self.from(obj)
  case obj
  when Nanoc::Core::StringPattern, Nanoc::Core::RegexpPattern
    obj
  when String
    Nanoc::Core::StringPattern.new(obj)
  when Regexp
    Nanoc::Core::RegexpPattern.new(obj)
  when Symbol
    Nanoc::Core::StringPattern.new(obj.to_s)
  else
    raise ArgumentError, "Do not know how to convert `#{obj.inspect}` into a Nanoc::Pattern"
  end
end

Instance Method Details

#captures(_identifier) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/nanoc/core/pattern.rb', line 32

def captures(_identifier)
  raise NotImplementedError
end

#match?(_identifier) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/nanoc/core/pattern.rb', line 28

def match?(_identifier)
  raise NotImplementedError
end