Class: Mustermann::Shell

Inherits:
Pattern
  • Object
show all
Includes:
Concat::Native
Defined in:
lib/mustermann/shell.rb

Overview

Matches strings that are identical to the pattern.

Examples:

Mustermann.new('/*.*', type: :shell) === '/bar' # => false

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(string, **options) ⇒ Shell

Returns a new instance of Shell.



34
35
36
37
# File 'lib/mustermann/shell.rb', line 34

def initialize(string, **options)
  @flags = File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB
  super(string, **options)
end

Instance Method Details

#===(string) ⇒ Object



42
43
44
# File 'lib/mustermann/shell.rb', line 42

def ===(string)
  File.fnmatch? @string, unescape(string), @flags
end

#peek_size(string) ⇒ Object



49
50
51
52
# File 'lib/mustermann/shell.rb', line 49

def peek_size(string)
  @peek_string ||= @string + "{**,/**,/**/*}"
  super if File.fnmatch? @peek_string, unescape(string), @flags
end