| Class | Uttk::Filters::NodeCut |
| In: |
lib/uttk/filters/NodeCut.rb
|
| Parent: | KeepSkipBased |
FIXME Can be path based This filter cut nodes which match `keep’ but not `skip‘
options:
keep: A regular expression (all keys which match this regexp are cut)
skip: Antoher regexp that skip keys which match
prune: Completly cut all sub nodes of a cut one
# File lib/uttk/filters/NodeCut.rb, line 22 def initialize ( *a, &b ) super @pruning_path = Set.new @pruning_path_node = nil end
# File lib/uttk/filters/NodeCut.rb, line 73 def pruning_path? ( path ) return false unless @pruning_path_node @pruning_path_node.each_with_index do |seg, i| return false if seg != path[i] end return true end
# File lib/uttk/filters/NodeCut.rb, line 29 def new_node ( path, node ) if @pruning_path_node or keep? node.segment super elsif prune? @pruning_path << path.to_s @pruning_path_node = path.dup << node else @pruning_path << path.to_s end end
# File lib/uttk/filters/NodeCut.rb, line 55 def notif ( msg, *args ) return super if args.first.nil? path = args.shift return if pruning_path? path copy = path.dup copy.delete_if do |x| skip? x.segment end super(msg, copy, *args) end