Class: PathFilter
- Inherits:
-
Object
- Object
- PathFilter
- Defined in:
- lib/path_filter.rb
Defined Under Namespace
Classes: Trie
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #each_entry(entries) ⇒ Object
-
#initialize(routes = Trie.new(true), path = Pathname.new("")) ⇒ PathFilter
constructor
A new instance of PathFilter.
- #join(name) ⇒ Object
Constructor Details
#initialize(routes = Trie.new(true), path = Pathname.new("")) ⇒ PathFilter
Returns a new instance of PathFilter.
29 30 31 32 |
# File 'lib/path_filter.rb', line 29 def initialize(routes = Trie.new(true), path = Pathname.new("")) @routes = routes @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
23 24 25 |
# File 'lib/path_filter.rb', line 23 def path @path end |
Class Method Details
.build(paths) ⇒ Object
25 26 27 |
# File 'lib/path_filter.rb', line 25 def self.build(paths) PathFilter.new(Trie.from_paths(paths)) end |
Instance Method Details
#each_entry(entries) ⇒ Object
34 35 36 37 38 |
# File 'lib/path_filter.rb', line 34 def each_entry(entries) entries.each do |name, entry| yield name, entry if @routes.matched or @routes.children.has_key?(name) end end |
#join(name) ⇒ Object
40 41 42 43 |
# File 'lib/path_filter.rb', line 40 def join(name) next_routes = @routes.matched ? @routes : @routes.children[name] PathFilter.new(next_routes, @path.join(name)) end |