Class: Cuboid::Support::Glob
Overview
Instance Attribute Summary collapse
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
Class Method Summary collapse
Instance Method Summary collapse
- #=~(str) ⇒ Object (also: #matches?)
-
#initialize(glob) ⇒ Glob
constructor
A new instance of Glob.
Constructor Details
#initialize(glob) ⇒ Glob
Returns a new instance of Glob.
14 15 16 |
# File 'lib/cuboid/support/glob.rb', line 14 def initialize( glob ) @regexp = self.class.to_regexp( glob ) end |
Instance Attribute Details
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
12 13 14 |
# File 'lib/cuboid/support/glob.rb', line 12 def regexp @regexp end |
Class Method Details
.to_regexp(glob) ⇒ Object
7 8 9 10 |
# File 'lib/cuboid/support/glob.rb', line 7 def self.to_regexp( glob ) escaped = Regexp.escape( glob ).gsub( '\*', '.*?' ) Regexp.new( "^#{escaped}$", Regexp::IGNORECASE ) end |
Instance Method Details
#=~(str) ⇒ Object Also known as: matches?
18 19 20 |
# File 'lib/cuboid/support/glob.rb', line 18 def =~( str ) @regexp.match? str end |