Class: RServiceBus2::Globber

Inherits:
Object
  • Object
show all
Defined in:
lib/rservicebus2/cron_manager.rb

Overview

Globber

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Globber

Returns a new instance of Globber.



13
14
15
# File 'lib/rservicebus2/cron_manager.rb', line 13

def initialize(str)
  @regex = self.class.parse_to_regex str
end

Class Method Details

.parse_to_regex(str) ⇒ Object



8
9
10
11
# File 'lib/rservicebus2/cron_manager.rb', line 8

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

Instance Method Details

#=~(str) ⇒ Object



17
18
19
# File 'lib/rservicebus2/cron_manager.rb', line 17

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