Class: GoogleDriveWildcard
- Inherits:
-
Object
- Object
- GoogleDriveWildcard
- Defined in:
- lib/googledrive/wildcard.rb
Overview
wildcard search. For file matching.
Class Method Summary collapse
Instance Method Summary collapse
- #=~(str) ⇒ Object
-
#initialize(str) ⇒ GoogleDriveWildcard
constructor
A new instance of GoogleDriveWildcard.
Constructor Details
#initialize(str) ⇒ GoogleDriveWildcard
Returns a new instance of GoogleDriveWildcard.
10 11 12 |
# File 'lib/googledrive/wildcard.rb', line 10 def initialize(str) @regex = self.class.parse_to_regex str end |
Class Method Details
.parse_to_regex(str) ⇒ Object
5 6 7 8 |
# File 'lib/googledrive/wildcard.rb', line 5 def self.parse_to_regex(str) escaped = Regexp.escape(str).gsub('\*','.*?') Regexp.new "^#{escaped}$", Regexp::IGNORECASE end |
Instance Method Details
#=~(str) ⇒ Object
14 15 16 |
# File 'lib/googledrive/wildcard.rb', line 14 def =~(str) !!(str =~ @regex) end |