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, build, #each_pair, #merge!, #retreive
Methods included from Unpath
#collapse, #repath, #string_to_segments, #unpath
Constructor Details
#initialize(segment) ⇒ FileGlob
Returns a new instance of FileGlob.
113 114 115 116 |
# File 'lib/valise/path-matcher.rb', line 113 def initialize(segment) super @regex = %r{^#{segment.gsub(/[*]/,".*")}$} end |
Instance Method Details
#match?(segment) ⇒ Boolean
118 119 120 |
# File 'lib/valise/path-matcher.rb', line 118 def match?(segment) @regex =~ segment end |
#store(segments, result) ⇒ Object
122 123 124 125 126 127 128 |
# File 'lib/valise/path-matcher.rb', line 122 def store(segments, result) if segments.empty? @value = result else raise ArgumentError, "File globs can only be used as suffixes" end end |