Class: DeviseJwtAuth::Url::Wildcat

Inherits:
Object
  • Object
show all
Defined in:
lib/devise_jwt_auth/url.rb

Overview

wildcard convenience class

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Wildcat

Returns a new instance of Wildcat.



34
35
36
# File 'lib/devise_jwt_auth/url.rb', line 34

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

Class Method Details

.parse_to_regex(str) ⇒ Object



29
30
31
32
# File 'lib/devise_jwt_auth/url.rb', line 29

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

Instance Method Details

#match(str) ⇒ Object



38
39
40
# File 'lib/devise_jwt_auth/url.rb', line 38

def match(str)
  !!@regex.match(str)
end