Class: Treebis::DirAsHash::Blacklist::GlobNodeMatcher

Inherits:
MatcherWithTail show all
Extended by:
MatcherFactory
Defined in:
lib/treebis.rb

Direct Known Subclasses

GlobNodeMatcherDeep

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MatcherFactory

create_matcher

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

Returns:

  • (Boolean)


287
288
289
# File 'lib/treebis.rb', line 287

def head_include? str
  @re =~ str
end