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