Class: Treebis::DirAsHash::Blacklist::GlobNodeMatcher
- Inherits:
-
MatcherWithTail
- Object
- MatcherWithTail
- Treebis::DirAsHash::Blacklist::GlobNodeMatcher
- Extended by:
- MatcherFactory
- Defined in:
- lib/treebis.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #head_include?(str) ⇒ Boolean
-
#initialize(globtoken, tail) ⇒ GlobNodeMatcher
constructor
A new instance of GlobNodeMatcher.
Methods included from MatcherFactory
Methods inherited from MatcherWithTail
#include?, #submatcher, #tail=
Constructor Details
#initialize(globtoken, tail) ⇒ GlobNodeMatcher
Returns a new instance of GlobNodeMatcher.
278 279 280 281 282 283 284 285 286 |
# File 'lib/treebis.rb', line 278 def initialize globtoken, tail /(?:\*\*|\/)/ =~ globtoken and fail("use factory") /\*/ =~ globtoken or fail("no") regexp_str = globtoken.split('*').map do |x| Regexp.escape(x) end.join('.*?') @re = Regexp.new("\\A#{regexp_str}\\Z") self.tail = tail end |
Class Method Details
.get(globtoken, tail) ⇒ Object
270 271 272 273 274 275 276 |
# File 'lib/treebis.rb', line 270 def get globtoken, tail if /(?:\*\*|\/)/ =~ globtoken GlobNodeMatcherDeep.new(globtoken, tail) else new globtoken, tail end end |
Instance Method Details
#head_include?(str) ⇒ Boolean
287 288 289 |
# File 'lib/treebis.rb', line 287 def head_include? str @re =~ str end |