Class: DeviseTokenAuth::Url::Wildcat

Inherits:
Object
  • Object
show all
Defined in:
lib/devise_token_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.



28
29
30
# File 'lib/devise_token_auth/url.rb', line 28

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

Class Method Details

.parse_to_regex(str) ⇒ Object



23
24
25
26
# File 'lib/devise_token_auth/url.rb', line 23

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

Instance Method Details

#match(str) ⇒ Object



32
33
34
# File 'lib/devise_token_auth/url.rb', line 32

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