Class: Valise::SetFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/valise/set-filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSetFilter

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

#setObject

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

#filesObject



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