Class: Hx::Path::Pattern

Inherits:
Object
  • Object
show all
Includes:
Selector
Defined in:
lib/hx/path.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


73
# File 'lib/hx/path.rb', line 73

def accept_path?(path) ; !!(path =~ @regexp) ; end