Class: Mustermann::Shell
- Defined in:
- mustermann-contrib/lib/mustermann/shell.rb
Overview
Matches strings that are identical to the pattern.
Constant Summary
Constants included from Mustermann
CompileError, DEFAULT_TYPE, Error, ExpandError, ParseError, TrieError
Instance Attribute Summary
Attributes inherited from Pattern
Instance Method Summary collapse
-
#===(string) ⇒ Boolean
Whether or not the pattern matches the given string.
-
#initialize(string, **options) ⇒ Pattern
constructor
A new instance of Pattern.
-
#peek_size(string) ⇒ Integer?
The number of characters that match.
Methods inherited from Pattern
#+, #==, #=~, #eql?, #expand, #hash, #identity_params?, #match, #names, new, #params, #peek, #peek_match, #peek_params, supported?, supported_options, #to_proc, #to_s, #to_templates, #|
Methods included from Mustermann
Constructor Details
#initialize(string, **options) ⇒ Pattern
Returns a new instance of Pattern.
33 34 35 36 |
# File 'mustermann-contrib/lib/mustermann/shell.rb', line 33 def initialize(string, **) @flags = File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB super(string, **) end |
Instance Method Details
#===(string) ⇒ Boolean
Returns Whether or not the pattern matches the given string.
41 42 43 |
# File 'mustermann-contrib/lib/mustermann/shell.rb', line 41 def ===(string) File.fnmatch? @string, unescape(string), @flags end |
#peek_size(string) ⇒ Integer?
Returns the number of characters that match.
48 49 50 51 |
# File 'mustermann-contrib/lib/mustermann/shell.rb', line 48 def peek_size(string) @peek_string ||= @string + "{**,/**,/**/*}" super if File.fnmatch? @peek_string, unescape(string), @flags end |