Class: Valise::SetFilter
- Inherits:
-
Object
- Object
- Valise::SetFilter
- Defined in:
- lib/valise/set-filter.rb
Instance Attribute Summary collapse
-
#path_matcher ⇒ Object
readonly
Returns the value of attribute path_matcher.
-
#set ⇒ Object
Returns the value of attribute set.
Instance Method Summary collapse
- #exclude(pattern, flags = nil) ⇒ Object
- #files ⇒ Object
- #include(pattern, flags = nil) ⇒ Object
-
#initialize ⇒ SetFilter
constructor
A new instance of SetFilter.
Constructor Details
#initialize ⇒ SetFilter
Returns a new instance of SetFilter.
5 6 7 8 |
# File 'lib/valise/set-filter.rb', line 5 def initialize @path_matcher = PathMatcher.new @set = nil end |
Instance Attribute Details
#path_matcher ⇒ Object (readonly)
Returns the value of attribute path_matcher.
9 10 11 |
# File 'lib/valise/set-filter.rb', line 9 def path_matcher @path_matcher end |
#set ⇒ Object
Returns the value of attribute set.
10 11 12 |
# File 'lib/valise/set-filter.rb', line 10 def set @set end |
Instance Method Details
#exclude(pattern, flags = nil) ⇒ Object
16 17 18 |
# File 'lib/valise/set-filter.rb', line 16 def exclude(pattern, flags = nil) path_matcher.set(pattern, false, flags) end |
#files ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/valise/set-filter.rb', line 20 def files visited = {} set.each do |root| root.each do |segments| next unless path_matcher === segments unless visited.has_key?(segments) item = set.get(segments).present.first visited[segments] = item yield(item) end end end return visited end |
#include(pattern, flags = nil) ⇒ Object
12 13 14 |
# File 'lib/valise/set-filter.rb', line 12 def include(pattern, flags = nil) path_matcher.set(pattern, true, flags) end |