Class: Tomo::Configuration::Glob
- Inherits:
-
Object
- Object
- Tomo::Configuration::Glob
- Defined in:
- lib/tomo/configuration/glob.rb
Instance Method Summary collapse
-
#initialize(spec) ⇒ Glob
constructor
A new instance of Glob.
- #match?(str) ⇒ Boolean
- #to_s ⇒ Object
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
15 16 17 |
# File 'lib/tomo/configuration/glob.rb', line 15 def match?(str) regexp.match?(str) end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/tomo/configuration/glob.rb', line 19 def to_s spec end |