Class: Arachni::Support::Glob

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/support/glob.rb

Overview

Author:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(glob) ⇒ Glob

Returns a new instance of Glob.



22
23
24
# File 'lib/arachni/support/glob.rb', line 22

def initialize( glob )
    @regexp = self.class.to_regexp( glob )
end

Instance Attribute Details

#regexpObject (readonly)

Returns the value of attribute regexp.



20
21
22
# File 'lib/arachni/support/glob.rb', line 20

def regexp
  @regexp
end

Class Method Details

.to_regexp(glob) ⇒ Object



15
16
17
18
# File 'lib/arachni/support/glob.rb', line 15

def self.to_regexp( glob )
    escaped = Regexp.escape( glob ).gsub( '\*', '.*?' )
    Regexp.new( "^#{escaped}$", Regexp::IGNORECASE )
end

Instance Method Details

#=~(str) ⇒ Object Also known as: matches?



26
27
28
# File 'lib/arachni/support/glob.rb', line 26

def =~( str )
    !!(str =~ @regexp)
end