Class: Middleman::WebP::PathnameMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-webp/pathname_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(pattern = '**/*') ⇒ PathnameMatcher

Initializes matcher with given pattern.

pattern - Pattern to match pathnames against to. May be

string, glob, prog or regex.


8
9
10
# File 'lib/middleman-webp/pathname_matcher.rb', line 8

def initialize(pattern = '**/*')
  @pattern = pattern
end

Instance Method Details

#matches?(path) ⇒ Boolean

Checks given file against pattern.

file - File, Pathname or String

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/middleman-webp/pathname_matcher.rb', line 15

def matches?(path)
  return false if path.nil?

  send match_method, Pathname.new(path)
end