Class: Debase::FileFilter
Instance Method Summary collapse
- #accept?(file_path) ⇒ Boolean
- #disable ⇒ Object
- #enable ⇒ Object
- #exclude(file_path) ⇒ Object
- #include(file_path) ⇒ Object
-
#initialize ⇒ FileFilter
constructor
A new instance of FileFilter.
Constructor Details
#initialize ⇒ FileFilter
Returns a new instance of FileFilter.
121 122 123 |
# File 'lib/debase.rb', line 121 def initialize @enabled = false end |
Instance Method Details
#accept?(file_path) ⇒ Boolean
143 144 145 146 147 |
# File 'lib/debase.rb', line 143 def accept?(file_path) return true unless @enabled return false if file_path.nil? included.any? { |path| file_path.start_with?(path) } && excluded.all? { |path| !file_path.start_with?(path)} end |
#disable ⇒ Object
138 139 140 141 |
# File 'lib/debase.rb', line 138 def disable @enabled = false Debase.enable_file_filtering(@enabled); end |
#enable ⇒ Object
133 134 135 136 |
# File 'lib/debase.rb', line 133 def enable @enabled = true Debase.enable_file_filtering(@enabled); end |
#exclude(file_path) ⇒ Object
129 130 131 |
# File 'lib/debase.rb', line 129 def exclude(file_path) excluded << file_path unless included.delete(file_path) end |
#include(file_path) ⇒ Object
125 126 127 |
# File 'lib/debase.rb', line 125 def include(file_path) included << file_path unless excluded.delete(file_path) end |