Class: TermUtils::FF::FinderQuery
- Inherits:
-
Object
- Object
- TermUtils::FF::FinderQuery
- Defined in:
- lib/term_utils/ff/finder.rb
Overview
Represents a Query.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #each_filter(&block) ⇒ Object
-
#enter_directory(&block) ⇒ Object
Wether to enter a directory.
-
#exclude_entry(&block) ⇒ Object
Wether to exclue an entry from the results.
- #filter(kind, &block) ⇒ Object
-
#include_entry(&block) ⇒ Object
Wether to include an entry into the results.
-
#initialize ⇒ FinderQuery
constructor
A new instance of FinderQuery.
-
#skip_directory(&block) ⇒ Object
Wether not to enter a directory.
Constructor Details
#initialize ⇒ FinderQuery
Returns a new instance of FinderQuery.
83 84 85 86 87 88 89 |
# File 'lib/term_utils/ff/finder.rb', line 83 def initialize @min_depth = 0 @max_depth = nil @use_stat = false @entry_kind = nil @filters = [] end |
Instance Attribute Details
#entry_kind ⇒ String, ...
81 82 83 |
# File 'lib/term_utils/ff/finder.rb', line 81 def entry_kind @entry_kind end |
#max_depth ⇒ Integer?
77 78 79 |
# File 'lib/term_utils/ff/finder.rb', line 77 def max_depth @max_depth end |
#min_depth ⇒ Integer
75 76 77 |
# File 'lib/term_utils/ff/finder.rb', line 75 def min_depth @min_depth end |
#use_stat ⇒ Boolean
79 80 81 |
# File 'lib/term_utils/ff/finder.rb', line 79 def use_stat @use_stat end |
Instance Method Details
#each_filter(&block) ⇒ Object
118 119 120 |
# File 'lib/term_utils/ff/finder.rb', line 118 def each_filter(&block) @filters.each(&block) end |
#enter_directory(&block) ⇒ Object
Wether to enter a directory.
99 100 101 |
# File 'lib/term_utils/ff/finder.rb', line 99 def enter_directory(&block) filter(:enter, &block) end |
#exclude_entry(&block) ⇒ Object
Wether to exclue an entry from the results.
114 115 116 |
# File 'lib/term_utils/ff/finder.rb', line 114 def exclude_entry(&block) filter(:exclude, &block) end |
#filter(kind, &block) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/term_utils/ff/finder.rb', line 91 def filter(kind, &block) raise StandardError, 'wrong filter kind' unless %i[enter skip include exclude].include?(kind) raise StandardError, "missing #{kind} block" if block.nil? @filters << { kind: kind, block: block } end |
#include_entry(&block) ⇒ Object
Wether to include an entry into the results.
109 110 111 |
# File 'lib/term_utils/ff/finder.rb', line 109 def include_entry(&block) filter(:include, &block) end |
#skip_directory(&block) ⇒ Object
Wether not to enter a directory.
104 105 106 |
# File 'lib/term_utils/ff/finder.rb', line 104 def skip_directory(&block) filter(:skip, &block) end |