Class: FFIDB::Glob
- Inherits:
-
Object
- Object
- FFIDB::Glob
- Defined in:
- lib/ffidb/glob.rb
Instance Attribute Summary collapse
-
#compiled ⇒ Object
readonly
Returns the value of attribute compiled.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
- #===(string) ⇒ Boolean
-
#initialize(pattern, ignore_case: nil, match_substring: nil) ⇒ Glob
constructor
A new instance of Glob.
- #to_s ⇒ String
Constructor Details
#initialize(pattern, ignore_case: nil, match_substring: nil) ⇒ Glob
Returns a new instance of Glob.
8 9 10 11 12 13 14 |
# File 'lib/ffidb/glob.rb', line 8 def initialize(pattern, ignore_case: nil, match_substring: nil) @pattern = pattern.to_s regexp_pattern = Regexp.escape(@pattern).gsub('\*', '.*').gsub('\?', '.') regexp_pattern = "^#{regexp_pattern}$" unless match_substring = ignore_case ? Regexp::IGNORECASE : nil @compiled = Regexp.new(regexp_pattern, ) end |
Instance Attribute Details
#compiled ⇒ Object (readonly)
Returns the value of attribute compiled.
6 7 8 |
# File 'lib/ffidb/glob.rb', line 6 def compiled @compiled end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
5 6 7 |
# File 'lib/ffidb/glob.rb', line 5 def pattern @pattern end |
Instance Method Details
#===(string) ⇒ Boolean
24 25 26 |
# File 'lib/ffidb/glob.rb', line 24 def ===(string) self.compiled === string end |
#to_s ⇒ String
18 19 20 |
# File 'lib/ffidb/glob.rb', line 18 def to_s self.pattern end |