Class: Hx::Path::Pattern
Instance Method Summary collapse
- #accept_path?(path) ⇒ Boolean
-
#initialize(tokens) ⇒ Pattern
constructor
A new instance of Pattern.
Methods included from Selector
#&, #assume_circumfix, #elide_circumfix, #|, #~
Constructor Details
#initialize(tokens) ⇒ Pattern
Returns a new instance of Pattern.
63 64 65 66 67 68 69 70 71 |
# File 'lib/hx/path.rb', line 63 def initialize(tokens) @regexp = Regexp.new("^#{tokens.map { |token| case token when :doublestar; '.*' when :star; '[^/]*' else; Regexp.quote(token) end }}$") end |
Instance Method Details
#accept_path?(path) ⇒ Boolean
73 |
# File 'lib/hx/path.rb', line 73 def accept_path?(path) ; !!(path =~ @regexp) ; end |