Class: Valise::FileGlob
- Inherits:
-
PathMatcher
- Object
- PathMatcher
- Valise::FileGlob
- Defined in:
- lib/valise/path-matcher.rb
Instance Attribute Summary
Attributes inherited from PathMatcher
Instance Method Summary collapse
-
#initialize(segment) ⇒ FileGlob
constructor
A new instance of FileGlob.
- #match?(segment) ⇒ Boolean
- #store(segments, result) ⇒ Object
Methods inherited from PathMatcher
#[], #[]=, #access, #each_pair, #merge!, #retreive
Methods included from Unpath
Constructor Details
#initialize(segment) ⇒ FileGlob
Returns a new instance of FileGlob.
96 97 98 99 |
# File 'lib/valise/path-matcher.rb', line 96 def initialize(segment) super @regex = %r{.*#{segment.sub(/^[*]/,"")}$} end |
Instance Method Details
#match?(segment) ⇒ Boolean
101 102 103 |
# File 'lib/valise/path-matcher.rb', line 101 def match?(segment) @regex =~ segment end |
#store(segments, result) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/valise/path-matcher.rb', line 105 def store(segments, result) if segments.empty? @value = result else raise ArgumentError, "File globs can only be used as suffixes" end end |