Class: Valise::FileGlob

Inherits:
PathMatcher show all
Defined in:
lib/valise/path-matcher.rb

Instance Attribute Summary

Attributes inherited from PathMatcher

#segment

Instance Method Summary collapse

Methods inherited from PathMatcher

#[], #[]=, #access, #each_pair, #merge!, #retreive

Methods included from Unpath

#repath, #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

Returns:

  • (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