Class: PathFilter::Trie
- Inherits:
-
Struct
- Object
- Struct
- PathFilter::Trie
- Defined in:
- lib/path_filter.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#matched ⇒ Object
Returns the value of attribute matched.
Class Method Summary collapse
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children
4 5 6 |
# File 'lib/path_filter.rb', line 4 def children @children end |
#matched ⇒ Object
Returns the value of attribute matched
4 5 6 |
# File 'lib/path_filter.rb', line 4 def matched @matched end |
Class Method Details
.from_paths(paths) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/path_filter.rb', line 5 def self.from_paths(paths) root = Trie.node root.matched = true if paths.empty? paths.each do |path| trie = root path.each_filename { |name| trie = trie.children[name] } trie.matched = true end root end |
.node ⇒ Object
18 19 20 |
# File 'lib/path_filter.rb', line 18 def self.node Trie.new(false, Hash.new { |hash, key| hash[key] = Trie.node }) end |