Class: Tomo::Configuration::Glob

Inherits:
Object
  • Object
show all
Defined in:
lib/tomo/configuration/glob.rb

Instance Method Summary collapse

Constructor Details

#initialize(spec) ⇒ Glob

Returns a new instance of Glob.



6
7
8
9
10
11
12
13
# File 'lib/tomo/configuration/glob.rb', line 6

def initialize(spec)
  @spec = spec.to_s.freeze
  regexp_parts = @spec.split(/(\*)/).map do |part|
    part == "*" ? ".*" : Regexp.quote(part)
  end
  @regexp = Regexp.new(regexp_parts.join).freeze
  freeze
end

Instance Method Details

#match?(str) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/tomo/configuration/glob.rb', line 15

def match?(str)
  regexp.match?(str)
end

#to_sObject



19
20
21
# File 'lib/tomo/configuration/glob.rb', line 19

def to_s
  spec
end