Class: Mustermann::Shell

Inherits:
Pattern
  • Object
show all
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.



32
33
34
35
# File 'lib/mustermann/shell.rb', line 32

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

Instance Method Details

#===(string) ⇒ Object



40
41
42
# File 'lib/mustermann/shell.rb', line 40

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

#peek_size(string) ⇒ Object



47
48
49
50
# File 'lib/mustermann/shell.rb', line 47

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