Class: DeviseTokenAuth::Url::Wildcat
- Inherits:
-
Object
- Object
- DeviseTokenAuth::Url::Wildcat
- Defined in:
- lib/devise_token_auth/url.rb
Overview
wildcard convenience class
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(str) ⇒ Wildcat
constructor
A new instance of Wildcat.
- #match(str) ⇒ Object
Constructor Details
#initialize(str) ⇒ Wildcat
Returns a new instance of Wildcat.
35 36 37 |
# File 'lib/devise_token_auth/url.rb', line 35 def initialize(str) @regex = self.class.parse_to_regex(str) end |
Class Method Details
.parse_to_regex(str) ⇒ Object
30 31 32 33 |
# File 'lib/devise_token_auth/url.rb', line 30 def self.parse_to_regex(str) escaped = Regexp.escape(str).gsub('\*','.*?') Regexp.new("^#{escaped}$", Regexp::IGNORECASE) end |
Instance Method Details
#match(str) ⇒ Object
39 40 41 |
# File 'lib/devise_token_auth/url.rb', line 39 def match(str) !!@regex.match(str) end |